-
Notifications
You must be signed in to change notification settings - Fork 0
Support JWK Selection Strategy #4
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
base: main
Are you sure you want to change the base?
Conversation
Closes spring-projectsgh-16170 Signed-off-by: douxiaofeng99 <18600127780@163.com>
Reviewer's Guide by SourceryThis pull request introduces a JWK selection strategy to the Updated class diagram for NimbusJwtEncoderclassDiagram
class NimbusJwtEncoder {
-JWKSource jwkSource
-Converter~List~JWK~, JWK~ jwkSelector
+NimbusJwtEncoder(JWKSource jwkSource)
+setJwkSelector(Converter~List~JWK~, JWK~ jwkSelector)
+Jwt encode(JwtEncoderParameters parameters)
-JWK selectJwk(JwsHeader headers)
-String serialize(JwsHeader headers, JwtClaimsSet claims, JWK jwk)
}
NimbusJwtEncoder -- JWKSource : has
NimbusJwtEncoder -- Converter : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here. PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
Qodo Merge was enabled for this repository. To continue using it, please link your Git account with your Qodo account here. PR Code Suggestions ✨Explore these optional code suggestions:
|
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.
Hey @GuusArts - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider using a functional interface instead of
Converter<List<JWK>, JWK>
forjwkSelector
to improve readability. - The exception message in the default
jwkSelector
could be improved to suggest configuring aJwkSelector
.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
public void setJwkSelector(Converter<List<JWK>, JWK> jwkSelector) { | ||
if(null!=jwkSelector) | ||
this.jwkSelector = jwkSelector; | ||
} |
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.
suggestion: Clarify handling of a null parameter in setJwkSelector.
Currently, passing a null value to setJwkSelector results in no change. It may be clearer to either explicitly disallow null (by throwing an exception) or document that null is a no-op to avoid unintentional mistakes by clients.
public void setJwkSelector(Converter<List<JWK>, JWK> jwkSelector) { | |
if(null!=jwkSelector) | |
this.jwkSelector = jwkSelector; | |
} | |
public void setJwkSelector(Converter<List<JWK>, JWK> jwkSelector) { | |
if(jwkSelector == null) { | |
throw new IllegalArgumentException("jwkSelector cannot be null"); | |
} | |
this.jwkSelector = jwkSelector; | |
} |
public void setJwkSelector(Converter<List<JWK>, JWK> jwkSelector) { | ||
if(null!=jwkSelector) | ||
this.jwkSelector = jwkSelector; | ||
} |
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.
Suggestion: Improve code style consistency
public void setJwkSelector(Converter<List<JWK>, JWK> jwkSelector) { | |
if(null!=jwkSelector) | |
this.jwkSelector = jwkSelector; | |
} | |
public void setJwkSelector(Converter<List<JWK>, JWK> jwkSelector) { | |
if (jwkSelector != null) { | |
this.jwkSelector = jwkSelector; | |
} | |
} |
User description
Closes spring-projectsgh-16170
PR Type
Enhancement
Description
Introduced a customizable JWK selection strategy in
NimbusJwtEncoder
.Added a new
setJwkSelector
method to configure JWK selection logic.Replaced hardcoded JWK selection logic with a configurable converter.
Updated error handling for JWK selection to improve flexibility.
Changes walkthrough 📝
NimbusJwtEncoder.java
Introduced customizable JWK selection strategy
oauth2/oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/NimbusJwtEncoder.java
Converter, JWK>
for JWK selection.setJwkSelector
method for custom JWK selection logic.