GetIdentityProviderByID gets an identity provider by its globally unique resource ID without workspace filter. For use by login flow where workspace is not yet known — the workspace is resolved from the IDP entity.
(ctx context.Context, resourceID string)
| 104 | // GetIdentityProviderByID gets an identity provider by its globally unique resource ID without workspace filter. |
| 105 | // For use by login flow where workspace is not yet known — the workspace is resolved from the IDP entity. |
| 106 | func (s *Store) GetIdentityProviderByID(ctx context.Context, resourceID string) (*IdentityProviderMessage, error) { |
| 107 | q := qb.Q().Space(` |
| 108 | SELECT resource_id, workspace, name, domain, type, config |
| 109 | FROM idp |
| 110 | WHERE resource_id = ? |
| 111 | `, resourceID) |
| 112 | |
| 113 | query, args, err := q.ToSQL() |
| 114 | if err != nil { |
| 115 | return nil, errors.Wrapf(err, "failed to build sql") |
| 116 | } |
| 117 | |
| 118 | var idp IdentityProviderMessage |
| 119 | var workspace sql.NullString |
| 120 | var idpType string |
| 121 | var idpConfig string |
| 122 | if err := s.GetDB().QueryRowContext(ctx, query, args...).Scan( |
| 123 | &idp.ResourceID, &workspace, &idp.Title, &idp.Domain, &idpType, &idpConfig, |
| 124 | ); err != nil { |
| 125 | if err == sql.ErrNoRows { |
| 126 | return nil, nil |
| 127 | } |
| 128 | return nil, errors.Wrap(err, "failed to get identity provider") |
| 129 | } |
| 130 | if workspace.Valid { |
| 131 | idp.Workspace = workspace.String |
| 132 | } |
| 133 | idp.Type = convertIdentityProviderType(idpType) |
| 134 | idp.Config = convertIdentityProviderConfigString(idp.Type, idpConfig) |
| 135 | return &idp, nil |
| 136 | } |
| 137 | |
| 138 | func (s *Store) GetIdentityProvider(ctx context.Context, find *FindIdentityProviderMessage) (*IdentityProviderMessage, error) { |
| 139 | identityProviders, err := s.ListIdentityProviders(ctx, find) |
no test coverage detected