Files
dc-solon-gateway/.claude/memory/jeecg-token-mechanism.md
T
lianlonggangandClaude 020f112124 feat: 完成数据中心转发网关核心功能(真实联调通过)
核心功能(已连接真实源服务器验证):
- /sys/watchUserLogin 本地处理:RSA解密验证设备密码(防伪造) + 单飞换token + Redis缓存
- 业务接口经本地通配Controller手动HttpUtils透传至源服务器 + 401检测清缓存
- token失效三重自愈:10秒探活 + 预过期刷新 + 被动401兜底

配置隔离(dotenv风格)+ 安全:
- .env 存敏感信息不入库;app.yml 用 ${KEY} 占位符引用;EnvLoader启动前加载
- 移除fastjson(规避0day),JSON改用Solon内置snack4

联调修复多个Solon实际API问题(配置文件名/YAML插件/打包/redisx/注解路径等)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-05 15:32:17 +08:00

18 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: jeecg-token-mechanism
description: 源服务器jeecg的token机制(JWT+Redis双层、滑动续期),决定中转刷新策略
metadata:
type: reference
---
源服务器 jeecg 的 token 机制(调研 `data-center-boot-spring3` 代码得出):
- **JWT 带 exp**`JwtUtil.sign``withExpiresAt`,exp = 生成时间 + 3.5天),但 **exp 不是硬性过期**
- **真正失效条件**Redis key `prefix_user_token:<token>` 被删除(主动 logout 或 7天不活跃)。Redis TTL = 604800秒(7天)。
- **滑动续期**`ShiroRealm.jwtTokenRefresh()` 每次请求(Redis key 存在时)重置 TTL 为 7 天,且 JWT exp 到期时静默重签。
- **失效返回**HTTP 401body `"Token失效,请重新登录!"`token 从 `X-Access-Token` 请求头读取。
**对中转的影响**:中转每 10 秒探活会刷新源服务器 Redis TTL,token 实际不会自然过期(除非被主动 logout)。预过期刷新基于 JWT exp,因滑动续期很少触发,作为双保险保留。探活失效/被动401 后必须 `forceRefresh`(先清缓存再换新),否则命中失效 token 死循环。
**RSA**:源服务器 `RSAEncryptUtils.decrypt1``Cipher.getInstance("RSA")` = `RSA/ECB/PKCS1Padding`,公钥 X.509、私钥 PKCS#8、明文 UTF-8、密文 Base641024位。中转 `RsaEncryptUtil` 已对齐。