JWT Signature/Claims Set validation order #743
Replies: 2 comments 10 replies
-
Why not just parse the token directly and use that before calling jwtVerify? const payload = jose.decodeJwt(token) |
Beta Was this translation helpful? Give feedback.
-
@marcgreenstock thank you for taking the time to post a discussion As per the specification the order of JWT validation steps is not significant which in the end supports your wish. However, the validity or invalidity of the JWT Claim Set prior to signature validation should not be used to make ANY decisions without consideration. And because of the invalidity part, in a general JWT validation case, one must first do the signature validation to be able to discern between a JWT that's invalid because it has unexpected claims and one that fails to pass authenticity validation. This order that's present in As an aside, I would strongly suggest you use a certified openid client instead of handrolling OpenID Connect integration. |
Beta Was this translation helpful? Give feedback.
-
Hey @panva,
Thanks for this repo, I have a few suggestions that I would appreciate your feedback on.
My use-case requires parsing of the JWT claims prior to JWS validation, for instance, with a JWT signed using an OpenID Connect Discovery 1.0 JWK:
In the above example, the server will make two fetch requests, one to get the OpenID configuration and another to get the JWKs.
The main problem is that jose will perform these fetch requests prior to validation of the claims.
I propose
jwtVerify
performs thejwtPayload
verification prior tocompactVerify
so it doesn't needlessly execute thegetKey
function if the claims are invalid.It would also be great, since the payload will already be decoded, if the get key function signature provided the claims on the object in the second argument. e.g.
With this, the OpenID Connect Discovery example would be a little simpler:
Beta Was this translation helpful? Give feedback.
All reactions