Unable to parse claims without key #923
-
Before version 0.12.0 we are able to parse claim in JWT without using key like: Jwts.parser().parseClaimsJwt(jwtWithoutSignature). Is there any alternative if I am using version 0.12.0 or later, I just want to parse claims and I am using algorithm RS256 for. Please suggest me alternative of parseClaimsJwt |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
This question comes up from time to time.
The RFC also goes on to say this about the
Ignoring the That said I'd still like to understand your use case. Why do you want to parse the token if you cannot be assured the content is valid? Have you validated the token some other way? Do you not have access to the public key?I'd like to keep the discussion going, but if you want a quick and dirty answer.... A JWS (signed JWT) is formatted in 3 parts: You could remove the signature section, and replace the header. Start with the token:
Remove the signature:
Then replace the header with
Notice that the middle section of the original JWT did not change in the last block You can base64 URL decode it and you would see: {"sub":"1234567890","name":"John Doe","admin":true,"iat":1708017104,"exp":1708020704} Important The decoding of the payload is the easy part, the heavy lifting (and the important part) performed by JJWT is dealing with all of the security related concerns around tokens. |
Beta Was this translation helpful? Give feedback.
-
I think this may be related: we need to get the iss to lookup the associated keyset. kid is in the header, iss in the body, that's how we verify the token is issued by the issuer (signed with a key registered with the issuer). We're using version .10 so that works fine (the resolver passing both the header and the claims), but hitting a bit of a roadblock trying to upgrade since the locator is only now passing the header. |
Beta Was this translation helpful? Give feedback.
-
I'll bring it up to the 1ed tech folks, going to be an interesting debate. Thanks for all the background on this and your work on this library! |
Beta Was this translation helpful? Give feedback.
This question comes up from time to time.
From a security perspective this is bad idea and violates the RFC, the first line of the JWS RFC:
The RFC also goes on to say this about the
alg
header param (section 4.1.1):Ignoring the
alg
header or processing it differently would not aline with these statements.That said I'd still like to understand your use case. Why do you want to parse the token if you cannot be assured the content is valid?
Have…