Skip to content
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

Allow configuration of OAuth2LoginAuthenticationFilter.authenticationResultConverter #16349

Open
ckalan opened this issue Dec 28, 2024 · 2 comments
Labels
status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement

Comments

@ckalan
Copy link

ckalan commented Dec 28, 2024

Expected Behavior

OAuth2LoginAuthenticationFilter has a authenticationResultConverter property (link to code). It would be nice if we could set it through HttpSecurity.oauth2Login configuration during SecurityFilterChain registration

Current Behavior

It seems there is no way to set it to a custom converter through HttpSecurity builder. I tried registering a custom Converter bean implementation for the same type but it wasn't auto-wired through the setter method. I guess oauth2 login configurer doesn't attempt to find a converter bean during initialization.

Context

What I am trying to do is, capture some request parameters during the oauth login authorization flow and then access them after successful authentication. I have a custom OAuth2AuthorizationRequestResolver which appends additional attributes to the OAuth2AuthorizationRequest. After successful authentication, OAuth2LoginAuthenticationFilter obtains a OAuth2LoginAuthenticationToken and converts it to a OAuth2AuthenticationToken. It seems, there is no way to access the OAuth2AuthorizationRequest afterwards. So I need to have a custom converter there.

I use a BeanPostProcessor as a workaround to set the converter which seems to be working fine. I just thought it would be nice to have it configurable as OAuth2LoginAuthenticationFilter already have a public setter for that property.

@ckalan ckalan added status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Dec 28, 2024
@ckalan
Copy link
Author

ckalan commented Dec 28, 2024

I found another way to do this through custom OAuth2UserService, OidcUserService and OAuth2AccessTokenResponseClient implementations to copy custom authorization request attributes to the resulting OAuth2User attributes which looks like a better solution without any need for a custom OAuth2AuthenticationToken class that is created through authentication conversion I wanted before. So I am not sure if this request still makes sense

@rohan-naik07
Copy link

Can I work on this?? @ckalan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants