|
@@ -36,6 +36,7 @@ import org.springframework.security.web.server.authentication.RedirectServerAuth
|
|
import org.springframework.security.web.server.authentication.RedirectServerAuthenticationSuccessHandler;
|
|
import org.springframework.security.web.server.authentication.RedirectServerAuthenticationSuccessHandler;
|
|
import org.springframework.security.web.server.authentication.ServerAuthenticationEntryPointFailureHandler;
|
|
import org.springframework.security.web.server.authentication.ServerAuthenticationEntryPointFailureHandler;
|
|
import org.springframework.security.web.server.authentication.ServerAuthenticationFailureHandler;
|
|
import org.springframework.security.web.server.authentication.ServerAuthenticationFailureHandler;
|
|
|
|
+import org.springframework.security.web.server.authentication.ServerAuthenticationSuccessHandler;
|
|
import org.springframework.security.web.server.authentication.logout.LogoutWebFilter;
|
|
import org.springframework.security.web.server.authentication.logout.LogoutWebFilter;
|
|
import org.springframework.security.web.server.authentication.logout.SecurityContextServerLogoutHandler;
|
|
import org.springframework.security.web.server.authentication.logout.SecurityContextServerLogoutHandler;
|
|
import org.springframework.security.web.server.authentication.logout.ServerLogoutHandler;
|
|
import org.springframework.security.web.server.authentication.logout.ServerLogoutHandler;
|
|
@@ -503,11 +504,20 @@ public class ServerHttpSecurity {
|
|
|
|
|
|
private ServerAuthenticationFailureHandler serverAuthenticationFailureHandler;
|
|
private ServerAuthenticationFailureHandler serverAuthenticationFailureHandler;
|
|
|
|
|
|
|
|
+ private ServerAuthenticationSuccessHandler serverAuthenticationSuccessHandler = new RedirectServerAuthenticationSuccessHandler("/");
|
|
|
|
+
|
|
public FormLoginBuilder authenticationManager(ReactiveAuthenticationManager authenticationManager) {
|
|
public FormLoginBuilder authenticationManager(ReactiveAuthenticationManager authenticationManager) {
|
|
this.authenticationManager = authenticationManager;
|
|
this.authenticationManager = authenticationManager;
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public FormLoginBuilder serverAuthenticationSuccessHandler(
|
|
|
|
+ ServerAuthenticationSuccessHandler serverAuthenticationSuccessHandler) {
|
|
|
|
+ Assert.notNull(serverAuthenticationSuccessHandler, "serverAuthenticationSuccessHandler cannot be null");
|
|
|
|
+ this.serverAuthenticationSuccessHandler = serverAuthenticationSuccessHandler;
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+
|
|
public FormLoginBuilder loginPage(String loginPage) {
|
|
public FormLoginBuilder loginPage(String loginPage) {
|
|
this.serverAuthenticationEntryPoint = new RedirectServerAuthenticationEntryPoint(loginPage);
|
|
this.serverAuthenticationEntryPoint = new RedirectServerAuthenticationEntryPoint(loginPage);
|
|
this.requiresAuthenticationMatcher = ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, loginPage);
|
|
this.requiresAuthenticationMatcher = ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, loginPage);
|
|
@@ -557,7 +567,7 @@ public class ServerHttpSecurity {
|
|
authenticationFilter.setRequiresAuthenticationMatcher(this.requiresAuthenticationMatcher);
|
|
authenticationFilter.setRequiresAuthenticationMatcher(this.requiresAuthenticationMatcher);
|
|
authenticationFilter.setServerAuthenticationFailureHandler(this.serverAuthenticationFailureHandler);
|
|
authenticationFilter.setServerAuthenticationFailureHandler(this.serverAuthenticationFailureHandler);
|
|
authenticationFilter.setAuthenticationConverter(new ServerFormLoginAuthenticationConverter());
|
|
authenticationFilter.setAuthenticationConverter(new ServerFormLoginAuthenticationConverter());
|
|
- authenticationFilter.setServerAuthenticationSuccessHandler(new RedirectServerAuthenticationSuccessHandler("/"));
|
|
|
|
|
|
+ authenticationFilter.setServerAuthenticationSuccessHandler(this.serverAuthenticationSuccessHandler);
|
|
authenticationFilter.setServerSecurityContextRepository(this.serverSecurityContextRepository);
|
|
authenticationFilter.setServerSecurityContextRepository(this.serverSecurityContextRepository);
|
|
http.addFilterAt(authenticationFilter, SecurityWebFiltersOrder.FORM_LOGIN);
|
|
http.addFilterAt(authenticationFilter, SecurityWebFiltersOrder.FORM_LOGIN);
|
|
}
|
|
}
|