org adapter:jose 验签 —— RS256 写死、校 iss/aud、30s 容差、错误译人话(ADR-012;新依赖 jose,用户已批)

四项校验顺序即安全要点:algorithms 写死 RS256(绝不读 token header 的 alg,否则
alg:none 可绕过)、issuer、audience、clockTolerance 30 秒;jose 的错误经
explainJoseError 翻成人话后包成 TokenRejectedError,排错省时间。测试用
createLocalJWKSet 造本地 JWKS 当 Keycloak 替身,不联网,验签逻辑本身走同一个
jwtVerify。zod 的 .optional() 与本仓 exactOptionalPropertyTypes 有摩擦,
按 claims.ts::identityOf 已有的手法(undefined 就不带键)加了 toVerifiedClaims
做收窄,详见 task-3-report.md。
This commit is contained in:
xcs
2026-08-25 16:21:17 +08:00
parent 5108d7a580
commit cb143d6413
6 changed files with 228 additions and 0 deletions
+1
View File
@@ -26,6 +26,7 @@
"ajv-formats": "^3.0.1",
"drizzle-orm": "^0.45.2",
"hono": "^4.12.32",
"jose": "^5.10.0",
"pg": "^8.22.0",
"pg-boss": "^12.26.3",
"zod": "^4.4.3"