Skip to content

Commit

Permalink
fix: kid header is not required for key lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Nov 4, 2020
1 parent c0598fb commit 27cc5c0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions client_authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,16 @@ func (f *Fosite) AuthenticateClient(ctx context.Context, r *http.Request, form u
}

func findPublicKey(t *jwt.Token, set *jose.JSONWebKeySet, expectsRSAKey bool) (interface{}, error) {
keys := set.Keys
if len(keys) == 0 {
return nil, errors.WithStack(ErrInvalidRequest.WithHintf("The retrieved JSON Web Key Set does not contain any keys."))
}

kid, ok := t.Header["kid"].(string)
if !ok {
return nil, errors.WithStack(ErrInvalidRequest.WithHint("The JSON Web Token must contain a kid header value but did not."))
if ok {
keys = set.Key(kid)
}

keys := set.Key(kid)
if len(keys) == 0 {
return nil, errors.WithStack(ErrInvalidRequest.WithHintf("The JSON Web Token uses signing key with kid '%s', which could not be found.", kid))
}
Expand Down

0 comments on commit 27cc5c0

Please sign in to comment.