Bump github.com/MicahParks/keyfunc from 1.5.1 to 1.9.0
Bumps [github.com/MicahParks/keyfunc](https://github.com/MicahParks/keyfunc) from 1.5.1 to 1.9.0. - [Release notes](https://github.com/MicahParks/keyfunc/releases) - [Commits](https://github.com/MicahParks/keyfunc/compare/v1.5.1...v1.9.0) --- updated-dependencies: - dependency-name: github.com/MicahParks/keyfunc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
Ralf Haferkamp
parent
3f40a42bb2
commit
71e548189d
+22
-5
@@ -16,16 +16,33 @@ var (
|
||||
|
||||
// Keyfunc matches the signature of github.com/golang-jwt/jwt/v4's jwt.Keyfunc function.
|
||||
func (j *JWKS) Keyfunc(token *jwt.Token) (interface{}, error) {
|
||||
kid, alg, err := kidAlg(token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return j.getKey(alg, kid)
|
||||
}
|
||||
|
||||
func (m *MultipleJWKS) Keyfunc(token *jwt.Token) (interface{}, error) {
|
||||
return m.keySelector(m, token)
|
||||
}
|
||||
|
||||
func kidAlg(token *jwt.Token) (kid, alg string, err error) {
|
||||
kidInter, ok := token.Header["kid"]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("%w: could not find kid in JWT header", ErrKID)
|
||||
return "", "", fmt.Errorf("%w: could not find kid in JWT header", ErrKID)
|
||||
}
|
||||
kid, ok := kidInter.(string)
|
||||
kid, ok = kidInter.(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("%w: could not convert kid in JWT header to string", ErrKID)
|
||||
return "", "", fmt.Errorf("%w: could not convert kid in JWT header to string", ErrKID)
|
||||
}
|
||||
|
||||
return j.getKey(kid)
|
||||
alg, ok = token.Header["alg"].(string)
|
||||
if !ok {
|
||||
// For test coverage purposes, this should be impossible to reach because the JWT package rejects a token
|
||||
// without an alg parameter in the header before calling jwt.Keyfunc.
|
||||
return "", "", fmt.Errorf(`%w: the JWT header did not contain the "alg" parameter, which is required by RFC 7515 section 4.1.1`, ErrJWKAlgMismatch)
|
||||
}
|
||||
return kid, alg, nil
|
||||
}
|
||||
|
||||
// base64urlTrailingPadding removes trailing padding before decoding a string from base64url. Some non-RFC compliant
|
||||
|
||||
Reference in New Issue
Block a user