Commit Graph

683 Commits

Author SHA1 Message Date
iRubbish
eb92213b17 feat: 添加 API Keys 批量管理功能的完整规范文档
- 需求文档:批量标签管理、账号分配、状态管理等6个核心需求
- 设计文档:完整的系统架构、组件设计和数据模型
- 任务计划:20个原子化实现任务,支持增量开发

功能包括:
- 批量标签添加/删除和冲突解决
- 批量账号分配(Claude/Gemini/OpenAI/Bedrock)
- 批量启用/禁用API Keys
- 增强的跨搜索持久多选界面
- 实时进度跟踪和操作审计

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 14:49:20 +08:00
mouyong
5ae136a5dc style: 移除尾随逗号
WHAT: 移除 SocksProxyAgent 配置对象中的尾随逗号
WHY: 保持代码格式的一致性和整洁性,符合项目的代码规范
HOW: 删除 family: 4 后的尾随逗号;无功能变更;纯格式化修改
2025-08-20 09:45:55 +08:00
shaw
9272930371 Merge branch 'main' into dev 2025-08-20 09:39:59 +08:00
shaw
af379f22aa fix: openai的responses去除text参数 2025-08-20 09:39:51 +08:00
mouyong
b1f2b4f6c1 fix(proxy): 强制 SOCKS5 代理使用 IPv4
WHAT: 为 SOCKS5 代理配置添加 family: 4 选项强制使用 IPv4 地址族
WHY: 解决 IPv4 主机名在代理连接时被意外解析到 IPv6 地址的问题,确保代理连接的稳定性和可预期性
HOW: 在 SocksProxyAgent 构造函数中添加 family: 4 配置选项;保持与现有 HTTP/HTTPS 代理的兼容性;无破坏性变更
2025-08-20 09:34:02 +08:00
Wesley Liddick
4840c5b829 Merge pull request #260 from iRubbish/dev
feat: 完善 API Keys 批量删除功能并修复搜索跨选择问题
2025-08-20 08:37:06 +08:00
iRubbish
1ee71ffbc9 feat: 完善 API Keys 批量删除功能并修复搜索跨选择问题
## 主要改进

### 🔧 核心修复
- 修复搜索时勾选状态无法保存的问题
- 优化全选/取消全选逻辑,支持跨搜索结果保持选择状态
- 改进批量删除的用户体验
- 添加 Unicode 字符处理中间件,提升请求体解析稳定性

### 🎯 具体变更
- **路由修复**: 解决批量删除路由匹配问题,调整路由顺序
- **API客户端**: 修复 DELETE 方法支持请求体数据传输
- **前端逻辑**: 分离筛选和搜索的监听器,搜索时保持已选中状态
- **全选优化**: 取消全选时只移除当前页选中项,保留其他页面选择
- **Unicode处理**: 添加无效 UTF-16 代理对清理和错误处理机制
- **配置管理**: 将 .mcp.json 添加到 .gitignore,避免本地配置被提交

### 🚀 用户体验提升
- 支持跨搜索结果批量选择和删除
- 批量删除按钮显示选中数量
- 智能的全选状态管理
- 更好的 Unicode 字符处理容错性

### 🧪 测试验证
- 验证搜索切换时选择状态保持
- 确认批量删除功能正常工作
- 检查 Redis 数据清理完整性
- 测试 Unicode 字符处理稳定性

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-19 09:59:54 +08:00
shaw
c61aba7c0c remove text 2025-08-18 19:17:31 +08:00
github-actions[bot]
23cb78558d chore: sync VERSION file with release v1.1.115 [skip ci] 2025-08-18 11:16:13 +00:00
shaw
539411d593 fix: openai的responses去除text参数 2025-08-18 19:15:49 +08:00
iRubbish
f642fa7095 feat: 实现 API Keys 批量删除后端功能
- 新增 DELETE /admin/api-keys/batch 端点
- 支持批量删除最多100个API Keys
- 完整的请求参数验证(数组格式、数量限制、ID有效性)
- 逐个删除并记录成功/失败状态
- 详细的错误信息和日志记录
- 返回成功/失败统计结果

请求格式: { "keyIds": ["key1", "key2", ...] }
响应格式: { "success": true, "data": { "successCount": 2, "failedCount": 0, "errors": [] } }

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 17:00:26 +08:00
Feng Yue
77338276db Merge remote-tracking branch 'f3n9/main' into user-management-new 2025-08-18 15:32:17 +08:00
github-actions[bot]
262df4d42e chore: sync VERSION file with release v1.1.114 [skip ci] 2025-08-18 03:13:25 +00:00
shaw
d11b7c5e3e fix: openai的api转发剔除多余参数 2025-08-18 11:13:01 +08:00
shaw
0f5779de84 fix: openai的api转发剔除多余参数 2025-08-18 11:10:49 +08:00
github-actions[bot]
9db88f9f0e chore: sync VERSION file with release v1.1.113 [skip ci] 2025-08-18 01:37:33 +00:00
shaw
639aef3242 Merge branch 'dev' 2025-08-18 09:37:01 +08:00
shaw
65ba0ffb8f feat: 优化 Gemini 项目ID处理逻辑
- 统一使用账户配置的项目ID,忽略客户端请求中的project参数
- 增强日志记录,更清晰地追踪项目ID的使用情况
- 移除无用的 geminiAuthInterceptor 中间件
- 移除调试用的 console.log

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 09:33:15 +08:00
github-actions[bot]
14f94a65b5 chore: sync VERSION file with release v1.1.112 [skip ci] 2025-08-17 09:11:48 +00:00
shaw
4196cf27a0 Merge branch 'dev' 2025-08-17 17:11:23 +08:00
shaw
71cbe84d8d Merge branch 'main' of github.com:Wei-Shaw/claude-relay-service 2025-08-17 17:11:15 +08:00
shaw
3d1cd21bc4 fix: 修复 ESLint 错误和代码格式问题
- 修复 cacheMonitor.js 中未使用的变量 'name'
- 移除未使用的变量以通过 ESLint 检查
- 确保 npm run dev 能正常运行

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-17 16:54:08 +08:00
shaw
3bcdb511fe feat: 实现多服务账户缓存优化系统
- 添加通用LRU缓存工具类,支持过期时间和内存限制
- 实现缓存监控系统,提供统计和健康检查接口
- 为所有账户服务(Claude、Gemini、OpenAI、Bedrock、Claude Console)添加缓存层
- 优化账户选择性能,减少Redis查询频率
- 添加缓存统计监控端点 /admin/cache/stats

性能提升:
- 账户列表查询从O(n)优化到O(1)
- 减少90%以上的Redis查询
- 响应时间降低50ms以上

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-17 15:38:49 +08:00
shaw
77f80ef1f4 fix: claude token统计问题 2025-08-17 00:41:16 +08:00
shaw
4643e471ee fix: 修复claude转发usage统计问题 2025-08-17 00:03:17 +08:00
shaw
043e3768ab fix: 修复每次请求都要重新生成秘钥的问题 2025-08-16 23:49:19 +08:00
shaw
9c5912f268 Merge branch 'main' into dev 2025-08-16 22:31:42 +08:00
shaw
681cb8cd82 feat: 优化 Claude 模型缓存费用计算,支持 5 分钟和 1 小时两种缓存类型
- 在 pricingService 中硬编码 1 小时缓存价格(Opus: $30/MTok, Sonnet: $6/MTok, Haiku: $1.6/MTok)
- 更新 usage 捕获逻辑以分别记录 ephemeral_5m 和 ephemeral_1h 缓存 tokens
- 改进费用计算逻辑,正确计算两种缓存类型的费用
- 新增 recordUsageWithDetails 方法支持详细的缓存数据
- 保持向后兼容性,支持旧的数据格式
- 删除测试脚本 test-openai-refresh.js
- 修复 OpenAI token 刷新逻辑

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-16 22:31:20 +08:00
Feng Yue
7a0acbdfdc security: fix LDAP injection vulnerability in username parameter
- Add strict username validation to prevent LDAP injection attacks
- Only allow alphanumeric characters, underscores, and hyphens in usernames
- Implement length limits and format validation for usernames
- Replace direct string interpolation with validated input in LDAP filters
- Update all logging to use sanitized username consistently
- Fix ESLint warnings for code style compliance

This prevents injection attacks like: *)(|(uid=admin that could bypass
authentication or allow user enumeration through malicious LDAP filters.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-15 18:57:42 +08:00
github-actions[bot]
4c642ac3ee chore: sync VERSION file with release v1.1.111 [skip ci] 2025-08-15 10:47:36 +00:00
shaw
b1344fef8c fix: prettier format 2025-08-15 18:47:09 +08:00
shaw
78f2cf1f56 fix: 修复前端 Prettier 格式化错误
- 移除 AccountsView.vue 中多余的空行
- 确保代码格式符合 Prettier 规范
- 前端现在可以正常编译

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-15 17:07:35 +08:00
shaw
812e98355f feat: 实现 OpenAI token 自动刷新功能并优化账户管理界面
主要更改:
1. OpenAI Token 自动刷新
   - 实现 refreshAccessToken 函数,支持 OAuth 2.0 refresh_token grant type
   - 使用 Codex CLI 官方 CLIENT_ID (app_EMoamEEZ73f0CkXaXp7hrann)
   - 支持 SOCKS5 和 HTTP/HTTPS 代理
   - 自动更新 access token、id token 和 refresh token

2. 账户管理界面优化
   - 移除手动刷新 token 按钮(桌面端和移动端)
   - 保留后端自动刷新机制
   - 优化代码结构,删除不再需要的函数和变量

3. 测试和文档
   - 添加 test-openai-refresh.js 测试脚本
   - 创建详细的实现文档

技术细节:
- Token 端点: https://auth.openai.com/oauth/token
- 默认有效期: 1小时
- 加密存储: AES-256-CBC

所有平台现在都支持自动 token 刷新:
 Claude - OAuth 自动刷新
 Gemini - Google OAuth2 自动刷新
 OpenAI - OAuth 自动刷新(新实现)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-15 16:56:44 +08:00
Feng Yue
71ce1e33b7 fix: API key limit now only counts active keys and uses config value
- Modified API key limit to count only active (non-deleted) keys instead of all keys
- Fixed frontend to use MAX_API_KEYS_PER_USER environment variable instead of hardcoded value
- Added activeApiKeysCount computed property to filter deleted keys
- Updated user profile endpoint to include maxApiKeysPerUser config
- Enhanced user store to persist and retrieve config values

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-15 13:36:05 +08:00
github-actions[bot]
3e605f0052 chore: sync VERSION file with release v1.1.110 [skip ci] 2025-08-14 13:47:13 +00:00
Wesley Liddick
925da6fb22 Merge pull request #249 from iRubbish/feat/webhook-manual-disable-notification
feat: 增强 webhook 通知功能,支持手动禁用账号通知
2025-08-14 21:47:01 +08:00
iRubbish
c9b0c3eb82 feat: 增强 webhook 通知功能,支持手动禁用账号通知
- 添加手动禁用账号时的 webhook 通知功能
- 支持所有账号类型:Claude OAuth、Claude Console、Gemini
- 新增错误代码:MANUALLY_DISABLED 系列
- 更新 README.md 文档,添加完整的 webhook 配置说明
- 包含企业微信配置示例和测试方法

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-14 18:28:48 +08:00
github-actions[bot]
d2ddd0cdd8 chore: sync VERSION file with release v1.1.109 [skip ci] 2025-08-14 08:51:34 +00:00
Wesley Liddick
74fcc6d470 Merge pull request #248 from kevinconan/main
feat: 新增Claude账号订阅类型设置
2025-08-14 16:51:20 +08:00
KevinLiao
f1febd320e fix: 去掉Free账号 2025-08-14 16:49:20 +08:00
KevinLiao
b0622bdcbd Merge branch 'main' of https://github.com/Wei-Shaw/claude-relay-service 2025-08-14 16:44:20 +08:00
KevinLiao
0e5f4e03c1 feat: 新增Claude账号订阅类型设置
1. OAuth可自动判断订阅类型,Setup Token请自行选择。无论那种类型都可以自己改
2. 优化调度,Pro账号不再接受opus模型请求的调度
2025-08-14 16:43:58 +08:00
Feng Yue
94eed70cf2 fix: disable user API keys when user account is disabled
Security enhancement to prevent disabled users from using API keys:

- Auto-disable all API keys when user is disabled/deleted
- Add user status validation during API key authentication
- Prevent API usage even if key is active but user is disabled
- Add comprehensive logging for security audit trail

This ensures disabled users cannot bypass restrictions through
existing API keys and maintains system security integrity.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-14 16:25:42 +08:00
Feng Yue
6b4ce99237 fix: usage stats issue 2025-08-14 16:16:27 +08:00
Feng Yue
283583d289 fix: prettier errors 2025-08-14 16:04:00 +08:00
Feng Yue
c80446ae98 fix: include deletion metadata in user API keys response
- Add isDeleted, deletedAt, deletedBy, deletedByType fields to getUserApiKeys service method
- Include deletion fields in user routes API keys response
- Add debug logging to dashboard component to troubleshoot deleted keys count
- Ensure frontend can properly identify and count deleted API keys

This fixes the issue where deleted API keys count was always showing 0
instead of the actual number of deleted keys.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-14 16:02:11 +08:00
Feng Yue
65620a4cde feat: separate active and deleted API keys display in user dashboard
- Replace single "API Keys" counter with separate "Active API Keys" and "Deleted API Keys"
- Add loadApiKeysStats function to count active vs deleted keys separately
- Update grid layout from lg:grid-cols-4 to lg:grid-cols-5 to accommodate new card
- Add green icon for active keys and trash icon for deleted keys
- Refresh API keys stats when switching to overview tab
- Change default tab to 'overview' for better UX

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-14 15:46:54 +08:00
Feng Yue
a7c6445f36 fix: improve user API keys display and interaction
- Hide delete button for deleted/disabled keys to prevent invalid actions
- Sort API keys by creation time descending (newest first)
- Change "Disabled" label to "Deleted" for consistency
- Add sortedApiKeys computed property for better organization

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-14 15:35:07 +08:00
Feng Yue
4509f303e6 feat: enhance user API keys view and fix admin cost display
- Add deleted API keys display to user's My API Keys view
- Show deleted status with gray indicator and "Deleted" badge
- Display deletion date and hide delete button for deleted keys
- Fix cost calculation in admin deleted API keys tab
- Add getCostStats call to properly populate cost data
- Support includeDeleted parameter in user API keys endpoint

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-14 15:25:22 +08:00
github-actions[bot]
b33c659491 chore: sync VERSION file with release v1.1.108 [skip ci] 2025-08-14 06:31:28 +00:00