feat: 实现历史API Key自动关联功能

核心功能:
- AD用户登录时自动关联已存在的历史API Key
- 关联规则: API Key name字段与用户displayName完全匹配
- 自动设置owner字段完成关联,避免用户重新创建Key

实现逻辑:
1. 优先匹配owner字段(已关联的Key)
2. 如无owner匹配,尝试匹配name与displayName
3. 找到匹配历史Key后,自动设置owner完成关联

技术特性:
- 详细日志记录关联过程
- 支持JWT token中完整用户信息传递
- Redis数据自动更新owner字段
- 系统迁移兼容性处理

测试验证:
- 创建测试历史Key验证自动关联
- JWT token正确解析displayName字段
- Redis数据正确更新owner关联关系

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
iRubbish
2025-08-25 18:19:33 +08:00
parent 7624c383e8
commit f31f7c9385
3 changed files with 103 additions and 18 deletions

View File

@@ -66,6 +66,7 @@
"jsonwebtoken": "^9.0.2",
"ldapjs": "^3.0.7",
"morgan": "^1.10.0",
"node-fetch": "^2.7.0",
"ora": "^5.4.1",
"rate-limiter-flexible": "^5.0.5",
"socks-proxy-agent": "^8.0.2",