mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-06 18:52:13 +00:00
LogoutWebFilter supports anonymous users
Fixes gh-4540
This commit is contained in:
parent
5baf71f4a0
commit
5fd84a62b5
@ -47,7 +47,13 @@ public class LogoutWebFiter implements WebFilter {
|
||||
return this.requiresLogout.matches(exchange)
|
||||
.filter( result -> result.isMatch())
|
||||
.switchIfEmpty(chain.filter(exchange).then(Mono.empty()))
|
||||
.flatMap( result -> exchange.getPrincipal().cast(Authentication.class))
|
||||
.flatMap( result -> authentication(exchange))
|
||||
.flatMap( authentication -> this.logoutHandler.logout(new WebFilterExchange(exchange, chain), authentication));
|
||||
}
|
||||
|
||||
private Mono<Authentication> authentication(ServerWebExchange exchange) {
|
||||
return exchange.getPrincipal()
|
||||
.cast(Authentication.class)
|
||||
.defaultIfEmpty(this.anonymousAuthenticationToken);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user