JwtTimestampsValidator can require exp and nbf claims#17030
Merged
jzheaux merged 2 commits intospring-projects:mainfrom May 27, 2025
Merged
Conversation
jzheaux
requested changes
May 7, 2025
Contributor
jzheaux
left a comment
There was a problem hiding this comment.
Thanks, @FerencKemeny! I've leave my feedback inline.
.../oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/JwtAudienceValidator.java
Outdated
Show resolved
Hide resolved
...h2/oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/JwtIssuerValidator.java
Outdated
Show resolved
Hide resolved
...oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/JwtTimestampValidator.java
Outdated
Show resolved
Hide resolved
...oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/JwtTimestampValidator.java
Show resolved
Hide resolved
...oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/JwtTimestampValidator.java
Outdated
Show resolved
Hide resolved
...2-jose/src/test/java/org/springframework/security/oauth2/jwt/JwtTimestampValidatorTests.java
Show resolved
Hide resolved
...uth2-jose/src/test/java/org/springframework/security/oauth2/jwt/JwtIssuerValidatorTests.java
Outdated
Show resolved
Hide resolved
...h2/oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/JwtIssuerValidator.java
Outdated
Show resolved
Hide resolved
...h2/oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/JwtIssuerValidator.java
Show resolved
Hide resolved
.../oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/JwtAudienceValidator.java
Show resolved
Hide resolved
9a92ff2 to
291c6e7
Compare
This commit corrects the test that checks for both nbf and exp missing. It also adds one for just exp and on for just nbf. Issue spring-projectsgh-17004 Signed-off-by: Ferenc Kemeny <ferenc.kemeny79+oss@gmail.com>
Closes spring-projectsgh-17004 Signed-off-by: Ferenc Kemeny <ferenc.kemeny79+oss@gmail.com>
291c6e7 to
36513ff
Compare
jzheaux
approved these changes
May 9, 2025
Contributor
jzheaux
left a comment
There was a problem hiding this comment.
Thanks, @FerencKemeny, for the PR! We'll merge this shortly after we've wrapped up the 6.5 release.
Contributor
Author
|
Thank you, @jzheaux, for all of your help on the PR. Appreciated! |
jzheaux
approved these changes
May 13, 2025
Contributor
|
Thanks, @FerencKemeny! This has been merged into |
Contributor
Author
|
I could not figure out why my commits appear only "Partially verified" and "Unverified" after you've merged. Anyhow I hope I can do this part better next time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I implemented
requiredparameter inJwtTimestampValidator,JwtIssuerValidatorandJwtAudienceValidator. I left the function of the original constructors untouched. In the original implementation successful validation was returned even if timestamps, issues or audience claims were missing. So this way previous API, implementations are not breaking. With my changes it is possible now to specify more strict specification, to tell if the given claim is mandatory to present and indiate it with failed validation if the claim is missing.This is the feature indicated in #17004