Skip to content

Support OAuth2AuthorizationRequestCustomizer for DefaultOAuth2AuthorizationRequestResolver #5525

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

Closed
mhyeon-lee opened this issue Jul 16, 2018 · 5 comments
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)

Comments

@mhyeon-lee
Copy link
Contributor

mhyeon-lee commented Jul 16, 2018

Summary

I know project will support configurable OAuth2AuthorizationRequestResolver. (#5521)
but, It would be nice to provide a customizer to reuse the DefaultOAuth2AuthorizationRequestResolver.

Sample

public final class DefaultOAuth2AuthorizationRequestResolver implements OAuth2AuthorizationRequestResolver {
     private OAuth2AuthorizationRequestCustomizer authorizationRequestCustomizer;
     ...
     ...
     @Override
     public OAuth2AuthorizationRequest resolve(HttpServletRequest request) {
          ...
          ...
          OAuth2AuthorizationRequest.Builder authorizationRequestBuilder = builder
				.clientId(clientRegistration.getClientId())
				.authorizationUri(clientRegistration.getProviderDetails().getAuthorizationUri())
				.redirectUri(redirectUriStr)
				.scopes(clientRegistration.getScopes())
				.state(this.stateGenerator.generateKey())
				.additionalParameters(additionalParameters);
          this.authorizationRequestCustomizer.customize(request, authorizationRequestBuilder);
          return authorizationRequestBuilder.build();
      }
}

java config

http
     .oauth2Login()
     .authorizationEndpoint()
     .authorizationRequestCustomizer(customizer);
@jgrandja jgrandja added the in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) label Jul 17, 2018
@mhyeon-lee
Copy link
Contributor Author

this issue related: #5466

@jgrandja
Copy link
Contributor

Thank you for your feedback and suggestion @mhyeon-lee.

Please take a look at the tests below as they show you how to customize the OAuth2AuthorizationRequest :

Test 1
Test 2

I understand your main goal is to reuse instead of copy (as is the case with the current implementation scenario), however, I would prefer to avoid creating a new API if possible.

What are your thoughts on removing the final on DefaultOAuth2AuthorizationRequestResolver and providing a protected method that allows for this customization?

@jgrandja jgrandja added the status: waiting-for-feedback We need additional information before we can continue label Jul 18, 2018
@mhyeon-lee
Copy link
Contributor Author

Yes. What I want is to extract the desired value from the HttpServletRequest information(queryParam, Header ....) and apply it in the OAuth2AuthorizationRequest.

It will be enough to decorate and add information like Test Sample.

@jgrandja
Copy link
Contributor

@mhyeon-lee

It will be enough to decorate and add information like Test Sample

Sounds like the tests I provided will work for your use case? Would you mind closing this issue if this suits your needs?

@mhyeon-lee
Copy link
Contributor Author

@jgrandja
Yes, this is enough for now.
Thank you for your guidance.

@jgrandja jgrandja removed the status: waiting-for-feedback We need additional information before we can continue label Jul 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)
Projects
None yet
Development

No branches or pull requests

2 participants