-
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
Add a convenience expiration setter which takes a duration #60
Labels
Milestone
Comments
Good idea! I think
Thoughts? |
yep, that does make for a more fluent api. |
Is there any ETA when is this feature going to be available? Thanks! |
Pull requests (with tests! we enforce 100% code coverage) are welcome! |
Moving this to 1.0.0 in favor of using the JDK8+ |
pveeckhout
added a commit
to pveeckhout/jjwt
that referenced
this issue
Dec 25, 2023
The `expireAfter` method, accepting duration and timeUnit parameters, has been added to the JwtBuilder interface. This method calculates the JWT expiration date as either the issue time plus the duration or the system current time plus the duration if an issuedAt time hasn't been set. Additional tests for this feature have been included in `DefaultJwtParserTest.groovy`.
pveeckhout
added a commit
to pveeckhout/jjwt
that referenced
this issue
Dec 25, 2023
Two new tests have been added to DefaultJwtParserTest to validate JWT expiration behavior. The tests ensure that for the 'expireAfter()' method, duration must be more than 0 and timeUnit cannot be null. The error messages for these validation checks have also been modified for clarity.
pveeckhout
added a commit
to pveeckhout/jjwt
that referenced
this issue
Jan 10, 2024
The token expiry calculation logic has been cleaned up and optimized in DefaultJwtBuilder. A previously used optional stream has been replaced with a more straightforward if-else structure, leading to ease of code maintenance and improved readability.
pveeckhout
added a commit
to pveeckhout/jjwt
that referenced
this issue
Jan 10, 2024
A typographical error in the comments of the 'exp' function in JwtBuilder was corrected. The phrase "specified it if" was changed to "specified if it", making the comments clearer and easier to understand.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would imagine that when most people are setting an expiration on a JWT, they will be using some configured timeout duration (e.g. 15 minutes). the ClaimsMutator has a basic setExpiration helper which takes the expiration date. It would be great if you added a convenience method which took the duration and did the math to compute the final exipration date, something like:
Where the impl is something like:
The text was updated successfully, but these errors were encountered: