|
31 | 31 | import java.util.UUID;
|
32 | 32 | import java.util.function.Function;
|
33 | 33 |
|
| 34 | +import org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequest; |
| 35 | +import org.springframework.security.oauth2.client.endpoint.ReactiveOAuth2AccessTokenResponseClient; |
34 | 36 | import reactor.core.publisher.Mono;
|
35 | 37 | import reactor.util.context.Context;
|
36 | 38 |
|
@@ -621,14 +623,13 @@ private ReactiveAuthenticationManager getAuthenticationManager() {
|
621 | 623 | }
|
622 | 624 |
|
623 | 625 | private ReactiveAuthenticationManager createDefault() {
|
624 |
| - WebClientReactiveAuthorizationCodeTokenResponseClient client = new WebClientReactiveAuthorizationCodeTokenResponseClient(); |
625 |
| - ReactiveAuthenticationManager result = new OAuth2LoginReactiveAuthenticationManager(client, getOauth2UserService()); |
| 626 | + ReactiveAuthenticationManager result = new OAuth2LoginReactiveAuthenticationManager(getAccessTokenResponseClient(), getOauth2UserService()); |
626 | 627 |
|
627 | 628 | boolean oidcAuthenticationProviderEnabled = ClassUtils.isPresent(
|
628 | 629 | "org.springframework.security.oauth2.jwt.JwtDecoder", this.getClass().getClassLoader());
|
629 | 630 | if (oidcAuthenticationProviderEnabled) {
|
630 | 631 | OidcAuthorizationCodeReactiveAuthenticationManager oidc =
|
631 |
| - new OidcAuthorizationCodeReactiveAuthenticationManager(client, getOidcUserService()); |
| 632 | + new OidcAuthorizationCodeReactiveAuthenticationManager(getAccessTokenResponseClient(), getOidcUserService()); |
632 | 633 | ResolvableType type = ResolvableType.forClassWithGenerics(
|
633 | 634 | ReactiveJwtDecoderFactory.class, ClientRegistration.class);
|
634 | 635 | ReactiveJwtDecoderFactory<ClientRegistration> jwtDecoderFactory = getBeanOrNull(type);
|
@@ -788,6 +789,15 @@ private Map<String, String> getLinks() {
|
788 | 789 | return result;
|
789 | 790 | }
|
790 | 791 |
|
| 792 | + private ReactiveOAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> getAccessTokenResponseClient() { |
| 793 | + ResolvableType type = ResolvableType.forClassWithGenerics(ReactiveOAuth2AccessTokenResponseClient.class, OAuth2AuthorizationCodeGrantRequest.class); |
| 794 | + ReactiveOAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> bean = getBeanOrNull(type); |
| 795 | + if (bean == null) { |
| 796 | + return new WebClientReactiveAuthorizationCodeTokenResponseClient(); |
| 797 | + } |
| 798 | + return bean; |
| 799 | + } |
| 800 | + |
791 | 801 | private ReactiveClientRegistrationRepository getClientRegistrationRepository() {
|
792 | 802 | if (this.clientRegistrationRepository == null) {
|
793 | 803 | this.clientRegistrationRepository = getBeanOrNull(ReactiveClientRegistrationRepository.class);
|
|
0 commit comments