-
Notifications
You must be signed in to change notification settings - Fork 6k
JwtIssuerValidator handles issuer (iss) claim values as Strings and URLs #9137
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
Conversation
@cmouttet Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@cmouttet Thank you for signing the Contributor License Agreement! |
f1c1679
to
2dc4e76
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, @cmouttet, and for your patience while I was out of the office.
I've left one piece of feedback inline.
Also, will you please make sure that your comment uses "Closes gh-9136" instead of "Issue gh-9136"? If you do that, then GitHub will link this PR to that issue and also close the ticket when the PR is merged.
|
||
/** | ||
* Constructs a {@link JwtIssuerValidator} using the provided parameters | ||
* @param issuer - The issuer that each {@link Jwt} should have. | ||
*/ | ||
public JwtIssuerValidator(String issuer) { | ||
Assert.notNull(issuer, "issuer cannot be null"); | ||
this.validator = new JwtClaimValidator(JwtClaimNames.ISS, issuer::equals); | ||
|
||
Predicate<Object> testClaimValueURL = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you already considered
Predicate<Object> testClaimValue = (claimValue) ->
claimValue != null && issuer.equals(claimValue.toString())
as it simplifies the logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Josh, many thanks for your feedback. I simplified the logic as you suggested and pushed a fix-up commit. After the checks succeed I'll squash the commits and change the commit comment having "Closes ...".
- NimbusJwtDecoder uses claim set converters: issuer claim is converted to an URL object - JwtIssuerValidator (created by JwtValidators.createDefaultWithIssuer(String)) wraps a JwtClaimValidator<String> - because of different data types, equal() is always false This change allows both Strings and URLs as values of the issuer Closes spring-projectsgh-9136
Thanks, @cmouttet! This is now merged. |
This change allows both Strings and URLs as values of the issuer
Issue gh-9136