feat(auth): P2-2 Spring Security 无状态 JWT 认证链路 + UserSession 引擎上下文适配

- jjwt 0.12.6 HS256;密钥配置化(EIP4_AUTH_JWT_SECRET),启动期强度校验,不入仓库
- 密码兼容:复刻 framework EncryptUtil 无盐 MD5 + 常量时间比对(侦察证据见报告)
- JwtAuthFilter:SecurityContext + 引擎 UserSession(静态 ThreadLocal)请求级 set/finally clear,16线程×200次并发隔离单测
- SecurityConfig 双链:prod 严格 401 / 非 prod 保留对拍测试通道(单测断言生产关闭)
- EntityController.buildCtx 三级优先(asUser > JWT > ADMIN),修复 JWT ctx 被 ADMIN 默认覆盖
- 实测:登录签发/过滤 16 行与 DB 吻合/伪造过期全 401;ci.sh 全绿;手册新增 §5.29-5.31

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-11 13:37:34 +08:00
parent 19dcd74f9d
commit 33d793b825
21 changed files with 1453 additions and 14 deletions

View File

@@ -17,6 +17,15 @@ spring:
server:
port: 8084
# 认证(P2):本地自举默认 JWT 密钥。仅本地/对拍用,生产须经
# EIP4_AUTH_JWT_SECRET 覆盖 + profile=prod 启严格链。详见 application.yml 注释。
eip4:
auth:
jwt:
secret: ${EIP4_AUTH_JWT_SECRET:dev-only-eip4-jwt-secret-change-me-in-production-0123456789}
expire-seconds: 28800 # 8h
issuer: eip4-platform
logging:
level:
com.dsasp: INFO