serverAuthenticationFailureHandler->authenticationFailureHandler
Issue: gh-4822
This commit is contained in:
parent
692233e431
commit
5c83f92ddc
|
@ -513,7 +513,7 @@ public class ServerHttpSecurity {
|
|||
ServerHttpSecurity.this.defaultEntryPoints.add(new DelegateEntry(restMatcher, this.entryPoint));
|
||||
AuthenticationWebFilter authenticationFilter = new AuthenticationWebFilter(
|
||||
this.authenticationManager);
|
||||
authenticationFilter.setServerAuthenticationFailureHandler(new ServerAuthenticationEntryPointFailureHandler(this.entryPoint));
|
||||
authenticationFilter.setAuthenticationFailureHandler(new ServerAuthenticationEntryPointFailureHandler(this.entryPoint));
|
||||
authenticationFilter.setAuthenticationConverter(new ServerHttpBasicAuthenticationConverter());
|
||||
if(this.securityContextRepository != null) {
|
||||
authenticationFilter.setSecurityContextRepository(this.securityContextRepository);
|
||||
|
@ -541,7 +541,7 @@ public class ServerHttpSecurity {
|
|||
|
||||
private ServerWebExchangeMatcher requiresAuthenticationMatcher;
|
||||
|
||||
private ServerAuthenticationFailureHandler serverAuthenticationFailureHandler;
|
||||
private ServerAuthenticationFailureHandler authenticationFailureHandler;
|
||||
|
||||
private ServerAuthenticationSuccessHandler serverAuthenticationSuccessHandler = this.defaultSuccessHandler;
|
||||
|
||||
|
@ -561,7 +561,7 @@ public class ServerHttpSecurity {
|
|||
this.defaultEntryPoint = new RedirectServerAuthenticationEntryPoint(loginPage);
|
||||
this.serverAuthenticationEntryPoint = this.defaultEntryPoint;
|
||||
this.requiresAuthenticationMatcher = ServerWebExchangeMatchers.pathMatchers(HttpMethod.POST, loginPage);
|
||||
this.serverAuthenticationFailureHandler = new RedirectServerAuthenticationFailureHandler(loginPage + "?error");
|
||||
this.authenticationFailureHandler = new RedirectServerAuthenticationFailureHandler(loginPage + "?error");
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -575,8 +575,8 @@ public class ServerHttpSecurity {
|
|||
return this;
|
||||
}
|
||||
|
||||
public FormLoginSpec authenticationFailureHandler(ServerAuthenticationFailureHandler serverAuthenticationFailureHandler) {
|
||||
this.serverAuthenticationFailureHandler = serverAuthenticationFailureHandler;
|
||||
public FormLoginSpec authenticationFailureHandler(ServerAuthenticationFailureHandler authenticationFailureHandler) {
|
||||
this.authenticationFailureHandler = authenticationFailureHandler;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -612,7 +612,7 @@ public class ServerHttpSecurity {
|
|||
AuthenticationWebFilter authenticationFilter = new AuthenticationWebFilter(
|
||||
this.authenticationManager);
|
||||
authenticationFilter.setRequiresAuthenticationMatcher(this.requiresAuthenticationMatcher);
|
||||
authenticationFilter.setServerAuthenticationFailureHandler(this.serverAuthenticationFailureHandler);
|
||||
authenticationFilter.setAuthenticationFailureHandler(this.authenticationFailureHandler);
|
||||
authenticationFilter.setAuthenticationConverter(new ServerFormLoginAuthenticationConverter());
|
||||
authenticationFilter.setServerAuthenticationSuccessHandler(this.serverAuthenticationSuccessHandler);
|
||||
authenticationFilter.setSecurityContextRepository(this.securityContextRepository);
|
||||
|
|
|
@ -47,7 +47,7 @@ public class AuthenticationWebFilter implements WebFilter {
|
|||
|
||||
private Function<ServerWebExchange,Mono<Authentication>> authenticationConverter = new ServerHttpBasicAuthenticationConverter();
|
||||
|
||||
private ServerAuthenticationFailureHandler serverAuthenticationFailureHandler = new ServerAuthenticationEntryPointFailureHandler(new HttpBasicServerAuthenticationEntryPoint());
|
||||
private ServerAuthenticationFailureHandler authenticationFailureHandler = new ServerAuthenticationEntryPointFailureHandler(new HttpBasicServerAuthenticationEntryPoint());
|
||||
|
||||
private ServerSecurityContextRepository securityContextRepository = NoOpServerSecurityContextRepository.getInstance();
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class AuthenticationWebFilter implements WebFilter {
|
|||
WebFilterExchange webFilterExchange = new WebFilterExchange(exchange, chain);
|
||||
return this.authenticationManager.authenticate(token)
|
||||
.flatMap(authentication -> onAuthenticationSuccess(authentication, webFilterExchange))
|
||||
.onErrorResume(AuthenticationException.class, e -> this.serverAuthenticationFailureHandler
|
||||
.onErrorResume(AuthenticationException.class, e -> this.authenticationFailureHandler
|
||||
.onAuthenticationFailure(webFilterExchange, e));
|
||||
}
|
||||
|
||||
|
@ -99,10 +99,10 @@ public class AuthenticationWebFilter implements WebFilter {
|
|||
this.authenticationConverter = authenticationConverter;
|
||||
}
|
||||
|
||||
public void setServerAuthenticationFailureHandler(
|
||||
ServerAuthenticationFailureHandler serverAuthenticationFailureHandler) {
|
||||
Assert.notNull(serverAuthenticationFailureHandler, "authenticationFailureHandler cannot be null");
|
||||
this.serverAuthenticationFailureHandler = serverAuthenticationFailureHandler;
|
||||
public void setAuthenticationFailureHandler(
|
||||
ServerAuthenticationFailureHandler authenticationFailureHandler) {
|
||||
Assert.notNull(authenticationFailureHandler, "authenticationFailureHandler cannot be null");
|
||||
this.authenticationFailureHandler = authenticationFailureHandler;
|
||||
}
|
||||
|
||||
public void setRequiresAuthenticationMatcher(
|
||||
|
|
|
@ -72,7 +72,7 @@ public class AuthenticationWebFilterTests {
|
|||
this.filter.setServerAuthenticationSuccessHandler(this.successHandler);
|
||||
this.filter.setAuthenticationConverter(this.authenticationConverter);
|
||||
this.filter.setSecurityContextRepository(this.securityContextRepository);
|
||||
this.filter.setServerAuthenticationFailureHandler(this.failureHandler);
|
||||
this.filter.setAuthenticationFailureHandler(this.failureHandler);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue