AuthorizationWebFilter.java 文件源码

java
阅读 29 收藏 0 点赞 0 评论 0

项目:item-shop-reactive-backend 作者:
@Override
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
    return exchange.getPrincipal()
        .filter(p -> p instanceof Authentication)
        .then( p-> Mono.just((Authentication) p))
        .filter(authentication -> {
            return authentication != null && authentication.isAuthenticated();
        })
        .then(authentication -> {
            return source.getConfigAttributes(exchange).as( (Function<? super Flux<ConfigAttribute>, Mono<Boolean>>) a -> {
                return accessDecisionManager.decide(authentication, exchange, a);
            });
        })
        .filter(t -> t)
        .otherwiseIfEmpty(Mono.defer(() -> {
            return entryPoint.commence(exchange, new AuthenticationCredentialsNotFoundException("Not Found"));
        }))
        .then(sc -> {
            return chain.filter(exchange);
        });
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号