public class TokenCachePlugin
extends org.apache.shenyu.plugin.base.AbstractShenyuPlugin
Validates opaque tokens stored in Redis for two path types: - /rest/invoke/**: reads token from Header "token", validates {token}_loginInfo key, does NOT inject user info (mirrors original userInfoJson=null behavior). - /rest/zy/**: reads Bearer token from Authorization header, validates by Redis key, injects user info as X-Token-User-* request headers. - /rest/login/**: LOGIN mode — forwards to backend, on success generates UUID token, writes {token}_loginInfo to Redis, injects token into response JSON.
Supports multi-level bypass: rule skipAut overrides selector skipAut (finest granularity wins); noLoginPattern checked at both levels.
| 构造器和说明 |
|---|
TokenCachePlugin(org.springframework.data.redis.core.ReactiveStringRedisTemplate redisTemplate,
org.springframework.web.reactive.function.client.WebClient webClient)
Instantiates a new TokenCachePlugin.
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected reactor.core.publisher.Mono<java.lang.Void> |
doExecute(org.springframework.web.server.ServerWebExchange exchange,
org.apache.shenyu.plugin.api.ShenyuPluginChain chain,
org.apache.shenyu.common.dto.SelectorData selector,
org.apache.shenyu.common.dto.RuleData rule) |
int |
getOrder() |
java.lang.String |
named() |
boolean |
skip(org.springframework.web.server.ServerWebExchange exchange) |
execute, handleRuleIfNull, handleSelectorIfNullpublic TokenCachePlugin(org.springframework.data.redis.core.ReactiveStringRedisTemplate redisTemplate,
org.springframework.web.reactive.function.client.WebClient webClient)
redisTemplate - the reactive redis template (shared with CAS plugin)webClient - the web client for HTTP user info queriesprotected reactor.core.publisher.Mono<java.lang.Void> doExecute(org.springframework.web.server.ServerWebExchange exchange,
org.apache.shenyu.plugin.api.ShenyuPluginChain chain,
org.apache.shenyu.common.dto.SelectorData selector,
org.apache.shenyu.common.dto.RuleData rule)
doExecute 在类中 org.apache.shenyu.plugin.base.AbstractShenyuPluginpublic int getOrder()
public java.lang.String named()
public boolean skip(org.springframework.web.server.ServerWebExchange exchange)
Copyright © 2026 The Apache Software Foundation. All rights reserved.