───────────────────────── ClientManager ───────────────────────── GetClient loads the client by ID. Returns fosite.ErrInvalidClient when the row doesn't exist so fosite's error mapping can produce the right RFC 6749 §5.2 error code at the endpoint.
(ctx context.Context, id string)
| 104 | // when the row doesn't exist so fosite's error mapping can produce the |
| 105 | // right RFC 6749 §5.2 error code at the endpoint. |
| 106 | func (s *Storage) GetClient(ctx context.Context, id string) (fosite.Client, error) { |
| 107 | var c Client |
| 108 | c.ID = id |
| 109 | var secretHash *string |
| 110 | err := s.db(ctx).QueryRow(ctx, ` |
| 111 | SELECT client_name, redirect_uris, grant_types, response_types, |
| 112 | scopes, audiences, token_endpoint_auth_method, |
| 113 | client_secret_hash, public |
| 114 | FROM oauth_clients WHERE client_id = $1 |
| 115 | `, id).Scan( |
| 116 | &c.Name, &c.RedirectURIs, &c.GrantTypeStrings, &c.ResponseTypeStrings, |
| 117 | &c.ScopeStrings, &c.AudienceStrings, &c.TokenEndpointAuthMethodS, |
| 118 | &secretHash, &c.Public, |
| 119 | ) |
| 120 | if errors.Is(err, pgx.ErrNoRows) { |
| 121 | return nil, fosite.ErrInvalidClient |
| 122 | } |
| 123 | if err != nil { |
| 124 | return nil, err |
| 125 | } |
| 126 | if secretHash != nil { |
| 127 | c.SecretHash = []byte(*secretHash) |
| 128 | } |
| 129 | return &c, nil |
| 130 | } |
| 131 | |
| 132 | // ClientAssertionJWTValid is for the JWT-Bearer client authentication |
| 133 | // method (RFC 7523). We don't support that auth method — public |