-
Notifications
You must be signed in to change notification settings - Fork 6k
Add BearerTokenAuthenticationConverter #8975
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
40eecda
to
46cd836
Compare
46cd836
to
4fa15d0
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, @thecodinglog! I've left some feedback inline.
Also, would you be able to update OAuth2ResourceServerConfigurer
to use setAuthenticationConverter
instead of BearerTokenResolver
?
...org/springframework/security/oauth2/server/resource/web/BearerTokenAuthenticationFilter.java
Show resolved
Hide resolved
9a21650
to
c5f7982
Compare
Thanks for this PR @thecodinglog , I needed exactly this to implement a feature that also needs to add additional information into the details. I've tried to use it on the current Spring Security version while waiting for 5.5.0, and I was wandering if it wouldn't be easier if The reason I asked this because today, you are forced to subclass Another option could be to use a bare |
c5f7982
to
553a083
Compare
Thanks for such a good opinion @benba . This PR focused on being able to change the I agree that If you need an interface for the setter It would be better to use As you mentioned, you may need a completely different implementation for I'm not sure I understand the last opinion which you mentioned but you mean that do the public void setBearerTokenResolver(BearerTokenResolver bearerTokenResolver) {
if(bearerTokenResolver instanceof BearerTokenAuthenticationConverter)
this.authenticationConverter = (BearerTokenAuthenticationConverter)bearerTokenResolver;
else
this.authenticationConverter.setBearerTokenResolver(bearerTokenResolver);
} If so, Since Thanks again!😃 |
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 again, @thecodinglog, and my apologies for the delay in responding. I've left some additional feedback inline.
Also, as a housekeeping item, will you please update the copyright headers in the files in this PR to have an end date of 2021? Thanks!
...ework/security/oauth2/server/resource/authentication/BearerTokenAuthenticationConverter.java
Outdated
Show resolved
Hide resolved
...ework/security/oauth2/server/resource/authentication/BearerTokenAuthenticationConverter.java
Outdated
Show resolved
Hide resolved
...config/annotation/web/configurers/oauth2/server/resource/OAuth2ResourceServerConfigurer.java
Show resolved
Hide resolved
...org/springframework/security/oauth2/server/resource/web/BearerTokenAuthenticationFilter.java
Outdated
Show resolved
Hide resolved
...org/springframework/security/oauth2/server/resource/web/BearerTokenAuthenticationFilter.java
Outdated
Show resolved
Hide resolved
BearerTokenAuthenticationConverter is introduced to solve the problem of not being able to change AuthenticationDetailsSource. BearerTokenAuthenticationFilter delegates to BearerTokenAuthenticationConverter the task of creating BearerTokenAuthenticationToken and setting AuthenticationDetailsSource. BearerTokenAuthenticationConverter is customizable and the customized converter can be used in BearerTokenAuthenticationFilter. Closes spring-projectsgh-8840
Thanks, @thecodinglog! This is now merged into I also added a polish via b774e91 that simplified a method name and rearranged some of the methods and fields. |
BearerTokenAuthenticationConverter is introduced to solve the problem of not being able to change AuthenticationDetailsSource.
Closes gh-8840