-
Notifications
You must be signed in to change notification settings - Fork 6.1k
JwtBearerTokenAuthenticationConverter Should Be In the Sample That Uses It #7354
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
Comments
Samples
I believe that there are several classes in Spring Security that are only used in the samples (or aren't used in the codebase at all, are just features available for applications). I'll list a few here, and we can see if
I've tried to list some from separate projects to hopefully capture any nuances to how we decide whether or not to keep this class where it is at. Additional ContextIt might be helpful if I expanded on some of the rationale already shared in #7346. I believe When using this class instead of the default For example: public String method(@AuthenticationPrincipal(expression="attributes['sub']") String subject) is more semantically correct than public String method(@AuthenticationPrincipal(expression="claims['sub']") String subject) since claims refer to a token in an unauthenticated state.
It has the additional benefit that the expression of an authenticated principal in Resource Server becomes unified: public String method(@AuthenticationPrincipal OAuth2AuthenticatedPrincipal) I affirm that while Secondary use-caseA secondary use-case is when applications support more than one mode of Resource Server authentication, as is demonstrated in the sample you refer to. In that case, it becomes critical to have a unified view of an authentication and its attributes, and this adapter removes boilerplate for the application. For example: public String method(@CurrentSecurityContext(expression="authentication.tokenAttributes['sub']") String subject) becomes public String method(@AuthenticationPrincipal(expression="attributes['sub'] String subject) Additionally public String method(AbstractOAuth2TokenAuthenticationToken<?> token) becomes public String method(BearerTokenAuthentication token) While this last example may seem minor, there is more than just line length going on here. I believe there is value in drawing a distinction between This is a move forward in this same direction. By using this converter, the application will use an |
I'll just add here one more nice thing about this class is that it will eventually simplify how an application customizes the |
Uh oh!
There was an error while loading. Please reload this page.
JwtBearerTokenAuthenticationConverter
is only used in a sample. Could we not extract this to the sample instead?Related #7346
The text was updated successfully, but these errors were encountered: