微服务改造
This commit is contained in:
@@ -95,12 +95,21 @@ public class GlobalAuthWebFilter implements WebFilter {
|
||||
// 5. 黑名单检查(仅当启用时)
|
||||
if (authProperties.isBlacklistEnabled()) {
|
||||
String blacklistKey = AuthConstants.BLACKLIST_PREFIX + principal.getId();
|
||||
Boolean isBlacklisted = redisTemplate.hasKey(blacklistKey).block();
|
||||
if (Boolean.TRUE.equals(isBlacklisted)) {
|
||||
return writeUnauthorized(exchange, AuthConstants.MSG_TOKEN_BLACKLISTED);
|
||||
}
|
||||
return redisTemplate.hasKey(blacklistKey).flatMap(isBlacklisted -> {
|
||||
if (Boolean.TRUE.equals(isBlacklisted)) {
|
||||
return writeUnauthorized(exchange, AuthConstants.MSG_TOKEN_BLACKLISTED);
|
||||
}
|
||||
return continueChain(exchange, chain, principal);
|
||||
}).onErrorResume(e -> {
|
||||
log.error("Redis check failed", e);
|
||||
return continueChain(exchange, chain, principal);
|
||||
});
|
||||
}
|
||||
|
||||
return continueChain(exchange, chain, principal);
|
||||
}
|
||||
|
||||
private Mono<Void> continueChain(ServerWebExchange exchange, WebFilterChain chain, AuthPrincipalVo principal) {
|
||||
// 6. 写入下游请求头
|
||||
String userInfoJson;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user