-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Align code in oauth2-client extensions for WebClient #6811
Comments
Resolved after merging #7116 |
@fritzdj @DarrenForsythe @philsttr @kujaomega @Vaelyr The purpose of this issue was to track related issues and associated PR's in order to resolve #6780 #6683 and to help with #6711. With the release of 5.2.0.RC1 (today), I'd like to provide some sample code/configuration to show usage of the new interfaces and associated implementations. I do plan on documenting all of this (and a lot more) in the reference manual but that work still needs to get done. I'm hoping by 5.2.0 GA or 5.2.1 at the latest. Please see the tests as they demonstrate various use case scenarios and usage of the new API's. ServletThe new interfaces are The default implementation for Here is a sample configuration: OAuth2AuthorizedClientProvider authorizedClientProvider =
OAuth2AuthorizedClientProviderBuilder.builder()
.authorizationCode()
.refreshToken()
.clientCredentials()
.password()
.build();
DefaultOAuth2AuthorizedClientManager authorizedClientManager = new DefaultOAuth2AuthorizedClientManager(
clientRegistrationRepository, authorizedClientRepository);
authorizedClientManager.setAuthorizedClientProvider(authorizedClientProvider); An instance of NOTE: ReactiveThe new interfaces are The default implementation for Here is a sample configuration: ReactiveOAuth2AuthorizedClientProvider authorizedClientProvider =
ReactiveOAuth2AuthorizedClientProviderBuilder.builder()
.authorizationCode()
.refreshToken()
.clientCredentials()
.password()
.build();
DefaultReactiveOAuth2AuthorizedClientManager authorizedClientManager = new DefaultReactiveOAuth2AuthorizedClientManager(
clientRegistrationRepository, authorizedClientRepository);
authorizedClientManager.setAuthorizedClientProvider(authorizedClientProvider); An instance of NOTE: "Outside of Request Context" (Non-Reactive)
For example, if your use case is to leverage the OAuth2AuthorizedClientProvider authorizedClientProvider =
OAuth2AuthorizedClientProviderBuilder.builder()
.clientCredentials()
.build();
AuthorizedClientServiceOAuth2AuthorizedClientManager authorizedClientManager = new AuthorizedClientServiceOAuth2AuthorizedClientManager(
clientRegistrationRepository, authorizedClientService);
authorizedClientManager.setAuthorizedClientProvider(authorizedClientProvider); NOTE: This implementation uses an WebSocketClient integrationIf you require Furthermore, if you require this for Servlet |
Great news, thanks a lot! |
The
WebClient
extensions for OAuth 2.0 Client are supported viaServletOAuth2AuthorizedClientExchangeFilterFunction
(Servlet) andServerOAuth2AuthorizedClientExchangeFilterFunction
(WebFlux).The
ServerOAuth2AuthorizedClientExchangeFilterFunction
(WebFlux) uses a collaboratorOAuth2AuthorizedClientResolver
to realize part of the feature set. However,ServletOAuth2AuthorizedClientExchangeFilterFunction
(Servlet) doesn't have such a collaborator and therefore all the code is contained within. We should consider adding anOAuth2AuthorizedClientResolver
equivalent for the Servlet version to align the code and provide consistency.Furthermore, as we continue to add support for other grant types, e.g. Resource Owner Password Credentials #6003, the code within each
ExchangeFilterFunction
could grow quite a bit making it more complex and harder to maintain. It is also preferred that the code in eachExchangeFilterFunction
is aligned/consistent and reused wherever possible. However, we need to be careful with reuse and ensure we don't introduce a blocking operation within the reactive implementation.As part of this decomposition exercise, we should consider re-structuring components/collaborators so they can potentially be reused by other technology stacks, e.g. WebFlux's
WebSocketClient
#6711,RestTemplate
or Feign Client.Related #6683, #6780
This issue is divided into the following tasks.
Servlet
OAuth2AuthorizedClientProvider
authorization_code
OAuth2AuthorizedClientProvider
client_credentials
OAuth2AuthorizedClientProvider
refresh_token
OAuth2AccessTokenResponseClient
refresh_token
OAuth2AuthorizedClientProvider
OAuth2AuthorizedClientProvider
OAuth2AuthorizedClientProvider
implementationsOAuth2AuthorizedClientProvider
to load/saveOAuth2AuthorizedClient
ClientCredentialsOAuth2AuthorizedClientProvider
should load/saveOAuth2AuthorizedClient
RefreshTokenOAuth2AuthorizedClientProvider
should load/saveOAuth2AuthorizedClient
Reactive
ReactiveOAuth2AuthorizedClientProvider
authorization_code
ReactiveOAuth2AuthorizedClientProvider
client_credentials
ReactiveOAuth2AuthorizedClientProvider
refresh_token
ReactiveOAuth2AccessTokenResponseClient
refresh_token
ReactiveOAuth2AuthorizedClientProvider
ReactiveOAuth2AuthorizedClientProvider
ReactiveOAuth2AuthorizedClientProvider
ReactiveOAuth2AuthorizedClientManager
ReactiveOAuth2AuthorizedClientManager/Provider
(s)The text was updated successfully, but these errors were encountered: