Skip to content

Commit 9f29c79

Browse files
committed
fix: key check order/clause for rsa and ec
1 parent f223c06 commit 9f29c79

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

goic.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,12 @@ func (g *Goic) verifyToken(p *Provider, tok *Token, nonce string) error {
259259

260260
for _, key := range p.wellKnown.jwks.Keys {
261261
kid := key.Kid == t.Header["kid"]
262-
if kid && key.Kty == "RSA" && key.Alg == alg {
263-
return &rsa.PublicKey{E: ParseExponent(key.E), N: ParseModulo(key.N)}, nil
264-
}
265262
if kid && key.Kty == "EC" && key.Alg == alg {
266263
return &ecdsa.PublicKey{X: ParseModulo(key.X), Y: ParseModulo(key.Y), Curve: GetCurve(key.Crv)}, nil
267264
}
265+
if kid && (key.Kty == "RSA" || key.Alg == alg) {
266+
return &rsa.PublicKey{E: ParseExponent(key.E), N: ParseModulo(key.N)}, nil
267+
}
268268
}
269269

270270
return nil, ErrTokenKey

0 commit comments

Comments
 (0)