-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to inspect body of signed JWT #67
Comments
With the
The signature is still validated, and the JWT instance will still not be returned if the jwt string is invalid, as expected. You just get to 'see' the JWT data for key discovery before the parser validates. As small sample of how to use it and look for the
|
Perfect, thank you. |
No worries! :) |
I am in the situation where a proxy should check the claims and expiration date of a signed token before passing it on. The proxy itself is not able to verify the signature, but I still want to be able to drop requests with invalid tokens (expired or missing claims). Is there a good way to do that currently? Should I just strip off the signature part using String manipulation? |
We have a similar problem. In the client, we only want to check if the token is expired or not and display a more informative message. We do not really care if the token was manipulated at this point, since our backend does the real verification. What would be a good way to do it? |
That should work until we figure out a way to (safely) make this available in the library. |
When attempting to read the body of a signed jwt without setting a key, an IllegalArgumentException is thrown. For example:
Jwts.parser().parseClaimsJws(someJwtString).getBody().get("iss")
. This makes sense, as it prevents users from ignoring signatures when they shouldn't.However, sometimes it is useful to know some fields of the body before checking the signature. For example, if there are several possible issuers to a token, each with different signing keys or signature mechanisms. Addition of a method like
parseUnsafe
would grant the ability to inspect the body as well as alert the user (through the name) of the danger of the method. The user could then go back and parse the jwt as normal with signature checking.The text was updated successfully, but these errors were encountered: