Add jwt as a property of JwtExceptions
See original GitHub issueWhen you try to parse the claims of a JWT, even when it fails validation, there may be instances where you would want to still read the claims.
Talking with @lhazlewood today, we came up with the following idea: adding the parsed JWT as a property of JwtException, so you could so something like:
try {
Jwts.parser().setSigningKey(key).parseClaimsJws(compactJws);
//OK, we can trust this JWT
} catch (ExpiredJwtException e) {
//don't trust the JWT!
String subject = e.jwt.getBody().getSubject();
System.out.println("Error: " + subject + "'s jwt failed valiation")
}
This would solve the #86 use case.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:9 (3 by maintainers)
Top Results From Across the Web
How to Handle JWTs in Python - Auth0
I am able to generate a jwt using python, but when I go to jwt.io, enter my generated token, add my secret (to...
Read more >Spring Security JWT Tutorial - Toptal
Set unauthorized requests exception handler. Set permissions on endpoints. Add JWT token filter. This configuration is implemented as follows:
Read more >Usage Examples — PyJWT 2.6.0 documentation
Some APIs require you to read a JWT header without validation. For example, in situations where the token issuer uses multiple keys and...
Read more >JSON web token (JWT) validation - Akamai TechDocs
Configure reserved JWT claims · On the JSON web tokens (JWT) settings page, in the Claims section, click Add claim and select the...
Read more >Implementing JSON Web Token (JWT) Authentication using ...
properties file and add the following property. jwt_secret=REPLACE_THIS_WITH_YOUR_SECRET. Make sure you choose a random and long string as your ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello, We are running into the same issue while attempting to parse claims from an expired token. We need a way to ignore that a token has expired, and allow other exceptions to be thrown. This assists to ensure that a token is from the correct originator, and allows us to use it, along with other validation information, to refresh for that user. Thanks for all of the hard work on this.
@bdemers thanks for the idea, I think I’ll go ahead with something like that.