|
@@ -41,6 +41,7 @@ import org.springframework.security.authorization.AuthorityReactiveAuthorization
|
|
import org.springframework.security.authorization.AuthorizationDecision;
|
|
import org.springframework.security.authorization.AuthorizationDecision;
|
|
import org.springframework.security.authorization.ReactiveAuthorizationManager;
|
|
import org.springframework.security.authorization.ReactiveAuthorizationManager;
|
|
import org.springframework.security.core.AuthenticationException;
|
|
import org.springframework.security.core.AuthenticationException;
|
|
|
|
+import org.springframework.security.oauth2.client.InMemoryReactiveOAuth2AuthorizedClientService;
|
|
import org.springframework.security.oauth2.client.ReactiveOAuth2AuthorizedClientService;
|
|
import org.springframework.security.oauth2.client.ReactiveOAuth2AuthorizedClientService;
|
|
import org.springframework.security.oauth2.client.authentication.OAuth2LoginReactiveAuthenticationManager;
|
|
import org.springframework.security.oauth2.client.authentication.OAuth2LoginReactiveAuthenticationManager;
|
|
import org.springframework.security.oauth2.client.endpoint.NimbusReactiveAuthorizationCodeTokenResponseClient;
|
|
import org.springframework.security.oauth2.client.endpoint.NimbusReactiveAuthorizationCodeTokenResponseClient;
|
|
@@ -361,11 +362,7 @@ public class ServerHttpSecurity {
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
- protected void configure(LoginPageGeneratingWebFilter loginPageFilter, ServerHttpSecurity http) {
|
|
|
|
- if (loginPageFilter != null) {
|
|
|
|
- loginPageFilter.setOauth2AuthenticationUrlToClientName(getLinks());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ protected void configure(ServerHttpSecurity http) {
|
|
ReactiveClientRegistrationRepository clientRegistrationRepository = getClientRegistrationRepository();
|
|
ReactiveClientRegistrationRepository clientRegistrationRepository = getClientRegistrationRepository();
|
|
ReactiveOAuth2AuthorizedClientService authorizedClientService = getAuthorizedClientService();
|
|
ReactiveOAuth2AuthorizedClientService authorizedClientService = getAuthorizedClientService();
|
|
OAuth2AuthorizationRequestRedirectWebFilter oauthRedirectFilter = new OAuth2AuthorizationRequestRedirectWebFilter(clientRegistrationRepository);
|
|
OAuth2AuthorizationRequestRedirectWebFilter oauthRedirectFilter = new OAuth2AuthorizationRequestRedirectWebFilter(clientRegistrationRepository);
|
|
@@ -417,6 +414,9 @@ public class ServerHttpSecurity {
|
|
if (this.authorizedClientService == null) {
|
|
if (this.authorizedClientService == null) {
|
|
this.authorizedClientService = getBeanOrNull(ReactiveOAuth2AuthorizedClientService.class);
|
|
this.authorizedClientService = getBeanOrNull(ReactiveOAuth2AuthorizedClientService.class);
|
|
}
|
|
}
|
|
|
|
+ if (this.authorizedClientService == null) {
|
|
|
|
+ this.authorizedClientService = new InMemoryReactiveOAuth2AuthorizedClientService(getClientRegistrationRepository());
|
|
|
|
+ }
|
|
return this.authorizedClientService;
|
|
return this.authorizedClientService;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -616,15 +616,24 @@ public class ServerHttpSecurity {
|
|
if(this.securityContextRepository != null) {
|
|
if(this.securityContextRepository != null) {
|
|
this.formLogin.securityContextRepository(this.securityContextRepository);
|
|
this.formLogin.securityContextRepository(this.securityContextRepository);
|
|
}
|
|
}
|
|
- if(this.formLogin.authenticationEntryPoint == null) {
|
|
|
|
|
|
+ if (this.authenticationEntryPoint == null) {
|
|
loginPageFilter = new LoginPageGeneratingWebFilter();
|
|
loginPageFilter = new LoginPageGeneratingWebFilter();
|
|
- this.webFilters.add(new OrderedWebFilter(loginPageFilter, SecurityWebFiltersOrder.LOGIN_PAGE_GENERATING.getOrder()));
|
|
|
|
- this.webFilters.add(new OrderedWebFilter(new LogoutPageGeneratingWebFilter(), SecurityWebFiltersOrder.LOGOUT_PAGE_GENERATING.getOrder()));
|
|
|
|
|
|
+ loginPageFilter.setFormLoginEnabled(true);
|
|
|
|
+ this.authenticationEntryPoint = this.formLogin.authenticationEntryPoint;
|
|
}
|
|
}
|
|
this.formLogin.configure(this);
|
|
this.formLogin.configure(this);
|
|
}
|
|
}
|
|
if (this.oauth2Login != null) {
|
|
if (this.oauth2Login != null) {
|
|
- this.oauth2Login.configure(loginPageFilter, this);
|
|
|
|
|
|
+ if (this.authenticationEntryPoint == null) {
|
|
|
|
+ loginPageFilter = new LoginPageGeneratingWebFilter();
|
|
|
|
+ loginPageFilter.setOauth2AuthenticationUrlToClientName(this.oauth2Login.getLinks());
|
|
|
|
+ }
|
|
|
|
+ this.oauth2Login.configure(this);
|
|
|
|
+ }
|
|
|
|
+ if (loginPageFilter != null) {
|
|
|
|
+ this.authenticationEntryPoint = new RedirectServerAuthenticationEntryPoint("/login");
|
|
|
|
+ this.webFilters.add(new OrderedWebFilter(loginPageFilter, SecurityWebFiltersOrder.LOGIN_PAGE_GENERATING.getOrder()));
|
|
|
|
+ this.webFilters.add(new OrderedWebFilter(new LogoutPageGeneratingWebFilter(), SecurityWebFiltersOrder.LOGOUT_PAGE_GENERATING.getOrder()));
|
|
}
|
|
}
|
|
if(this.logout != null) {
|
|
if(this.logout != null) {
|
|
this.logout.configure(this);
|
|
this.logout.configure(this);
|
|
@@ -638,8 +647,8 @@ public class ServerHttpSecurity {
|
|
exceptionTranslationWebFilter.setAuthenticationEntryPoint(
|
|
exceptionTranslationWebFilter.setAuthenticationEntryPoint(
|
|
authenticationEntryPoint);
|
|
authenticationEntryPoint);
|
|
}
|
|
}
|
|
- if(accessDeniedHandler != null) {
|
|
|
|
- exceptionTranslationWebFilter.setAccessDeniedHandler(accessDeniedHandler);
|
|
|
|
|
|
+ if(this.accessDeniedHandler != null) {
|
|
|
|
+ exceptionTranslationWebFilter.setAccessDeniedHandler(this.accessDeniedHandler);
|
|
}
|
|
}
|
|
this.addFilterAt(exceptionTranslationWebFilter, SecurityWebFiltersOrder.EXCEPTION_TRANSLATION);
|
|
this.addFilterAt(exceptionTranslationWebFilter, SecurityWebFiltersOrder.EXCEPTION_TRANSLATION);
|
|
this.authorizeExchange.configure(this);
|
|
this.authorizeExchange.configure(this);
|