Skip to content
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

#60 Add expireAfter functionality to JWT Builder #883

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

pveeckhout
Copy link

@pveeckhout pveeckhout commented Dec 25, 2023

closes #60

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 issuedAt 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.

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
Copy link
Author

Should I have forgotten some additional testing, or any other remarks, please do not hesitate to comment.

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.
@lhazlewood
Copy link
Contributor

Awesome, thanks for this! We can merge it in the context of #308.

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.
…_which_takes_a_duration' into 60-convenience_expiration_setter_which_takes_a_duration
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.
@lhazlewood lhazlewood added the jdk8 Changes related to migrating to JDK8 API features label Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jdk8 Changes related to migrating to JDK8 API features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a convenience expiration setter which takes a duration
2 participants