1111import lombok .RequiredArgsConstructor ;
1212import lombok .extern .slf4j .Slf4j ;
1313import org .jetbrains .annotations .Nullable ;
14- import org .springframework .beans .factory .annotation .Autowired ;
15- import org .springframework .beans .factory .annotation .Qualifier ;
1614import org .springframework .boot .autoconfigure .condition .ConditionalOnProperty ;
1715import org .springframework .boot .autoconfigure .security .oauth2 .client .OAuth2ClientProperties ;
1816import org .springframework .boot .autoconfigure .security .oauth2 .client .OAuth2ClientPropertiesMapper ;
1917import org .springframework .boot .autoconfigure .security .oauth2 .resource .OAuth2ResourceServerProperties ;
2018import org .springframework .boot .context .properties .EnableConfigurationProperties ;
2119import org .springframework .context .annotation .Bean ;
2220import org .springframework .context .annotation .Configuration ;
21+ import org .springframework .http .client .reactive .ReactorClientHttpConnector ;
2322import org .springframework .security .config .Customizer ;
2423import org .springframework .security .config .annotation .method .configuration .EnableReactiveMethodSecurity ;
2524import org .springframework .security .config .annotation .web .reactive .EnableWebFluxSecurity ;
4039import org .springframework .security .web .server .authentication .logout .ServerLogoutSuccessHandler ;
4140import org .springframework .web .reactive .function .client .WebClient ;
4241import reactor .core .publisher .Mono ;
42+ import reactor .netty .http .client .HttpClient ;
4343
4444@ Configuration
4545@ ConditionalOnProperty (value = "auth.type" , havingValue = "OAUTH2" )
@@ -92,7 +92,6 @@ public ReactiveOAuth2UserService<OidcUserRequest, OidcUser> customOidcUserServic
9292 ReactiveOAuth2UserService <OAuth2UserRequest , OAuth2User > oauth2UserService ) {
9393 final OidcReactiveOAuth2UserService delegate = new OidcReactiveOAuth2UserService ();
9494
95- // Use our custom OAuth2 user service which may have proxy support
9695 delegate .setOauth2UserService (oauth2UserService );
9796
9897 return request -> delegate .loadUser (request )
@@ -109,16 +108,15 @@ public ReactiveOAuth2UserService<OidcUserRequest, OidcUser> customOidcUserServic
109108 }
110109
111110 @ Bean
112- public ReactiveOAuth2UserService <OAuth2UserRequest , OAuth2User > customOauth2UserService (
113- AccessControlService acs ,
114- @ Autowired (required = false ) @ Qualifier ("oauth2WebClient" ) WebClient oauth2WebClient ) {
111+ public ReactiveOAuth2UserService <OAuth2UserRequest , OAuth2User > customOauth2UserService (AccessControlService acs ) {
115112 final DefaultReactiveOAuth2UserService delegate = new DefaultReactiveOAuth2UserService ();
116113
117- // If proxy-configured WebClient is available, use it
118- if (oauth2WebClient != null ) {
119- delegate .setWebClient (oauth2WebClient );
120- log .debug ("OAuth2 user service configured with custom WebClient (proxy support)" );
121- }
114+ // Configure WebClient to use system proxy properties (if set)
115+ delegate .setWebClient (
116+ WebClient .builder ()
117+ .clientConnector (new ReactorClientHttpConnector (
118+ HttpClient .create ().proxyWithSystemProperties ()))
119+ .build ());
122120
123121 return request -> delegate .loadUser (request )
124122 .flatMap (user -> {
0 commit comments