mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-05-31 09:12:14 +00:00
Remove wrappedExchange from AuthenticationWebFilter
Issue: gh-4719
This commit is contained in:
parent
9c31041dce
commit
5bcf3c559b
@ -52,7 +52,6 @@ public class AuthenticationWebFilter implements WebFilter {
|
||||
private ServerSecurityContextRepository serverSecurityContextRepository = new ServerWebExchangeAttributeServerSecurityContextRepository();
|
||||
|
||||
private ServerWebExchangeMatcher requiresAuthenticationMatcher = ServerWebExchangeMatchers.anyExchange();
|
||||
|
||||
public AuthenticationWebFilter(ReactiveAuthenticationManager authenticationManager) {
|
||||
Assert.notNull(authenticationManager, "authenticationManager cannot be null");
|
||||
this.authenticationManager = authenticationManager;
|
||||
@ -60,21 +59,16 @@ public class AuthenticationWebFilter implements WebFilter {
|
||||
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
ServerWebExchange wrappedExchange = new SecurityContextRepositoryServerWebExchange(exchange, this.serverSecurityContextRepository);
|
||||
return filterInternal(wrappedExchange, chain);
|
||||
}
|
||||
|
||||
private Mono<Void> filterInternal(ServerWebExchange wrappedExchange, WebFilterChain chain) {
|
||||
return this.requiresAuthenticationMatcher.matches(wrappedExchange)
|
||||
return this.requiresAuthenticationMatcher.matches(exchange)
|
||||
.filter( matchResult -> matchResult.isMatch())
|
||||
.flatMap( matchResult -> this.authenticationConverter.apply(wrappedExchange))
|
||||
.switchIfEmpty(chain.filter(wrappedExchange).then(Mono.empty()))
|
||||
.flatMap( token -> authenticate(wrappedExchange, chain, token));
|
||||
.flatMap( matchResult -> this.authenticationConverter.apply(exchange))
|
||||
.switchIfEmpty(chain.filter(exchange).then(Mono.empty()))
|
||||
.flatMap( token -> authenticate(exchange, chain, token));
|
||||
}
|
||||
|
||||
private Mono<Void> authenticate(ServerWebExchange wrappedExchange,
|
||||
private Mono<Void> authenticate(ServerWebExchange exchange,
|
||||
WebFilterChain chain, Authentication token) {
|
||||
WebFilterExchange webFilterExchange = new WebFilterExchange(wrappedExchange, chain);
|
||||
WebFilterExchange webFilterExchange = new WebFilterExchange(exchange, chain);
|
||||
return this.authenticationManager.authenticate(token)
|
||||
.flatMap(authentication -> onAuthenticationSuccess(authentication, webFilterExchange))
|
||||
.onErrorResume(AuthenticationException.class, e -> this.serverAuthenticationFailureHandler
|
||||
|
Loading…
x
Reference in New Issue
Block a user