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