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:
@@ -1,6 +1,10 @@
|
||||
spring:
|
||||
application:
|
||||
name: eip4-poc
|
||||
autoconfigure:
|
||||
# 认证走 JWT(非表单/Basic),排除默认内存用户管理:免生成误导性 dev 口令、免无用 AuthManager
|
||||
exclude:
|
||||
- org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration
|
||||
datasource:
|
||||
url: jdbc:postgresql://192.168.20.68:5435/postgres?currentSchema=eip3
|
||||
username: ceshi
|
||||
@@ -13,6 +17,19 @@ spring:
|
||||
server:
|
||||
port: 8084
|
||||
|
||||
# ============================================================================
|
||||
# 认证(P2):无状态 JWT。HS256 对称密钥配置化,严禁硬编码进 Java 代码。
|
||||
# 下方为「非生产默认值」——供 default/local/ci profile 自举开箱即用。
|
||||
# 生产部署务必经环境变量 EIP4_AUTH_JWT_SECRET 覆盖为强随机密钥(≥32 字节),
|
||||
# 并以 -Dspring.profiles.active=prod 启用严格安全链(其余 /api/** 强制认证)。
|
||||
# ============================================================================
|
||||
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: DEBUG
|
||||
|
||||
Reference in New Issue
Block a user