AuthorizationWebFilter handles null Authentication
If the AuthorizationManager used the Authentication and the Authentication was null the AuthorizationWebFilter would produce a NullPointerException This commit fixes the test to ensure that Authentication is subscribed to and ensures that the Authentication is not null Fixes: gh-4966
This commit is contained in:
@@ -40,6 +40,7 @@ public class AuthorizationWebFilter implements WebFilter {
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
return ReactiveSecurityContextHolder.getContext()
|
||||
.filter(c -> c.getAuthentication() != null)
|
||||
.map(SecurityContext::getAuthentication)
|
||||
.as(authentication -> this.accessDecisionManager.verify(authentication, exchange))
|
||||
.switchIfEmpty(chain.filter(exchange));
|
||||
|
||||
Reference in New Issue
Block a user