Commit Graph

75 Commits

Author SHA1 Message Date
CaIon 59c582d13c fix: harden token auth error handling to prevent info leakage
- Create model/errors.go to centralize all sentinel errors
- ValidateAccessToken now returns error to distinguish DB failures
- ValidateUserToken uses unified ErrTokenInvalid for all auth failures
  (expired/exhausted/disabled/not-found) to prevent token enumeration
- authHelper and TokenAuthReadOnly use i18n messages instead of
  hardcoded Chinese strings
- All err.Error() removed from user-facing responses; DB errors logged
  server-side and return generic "contact admin" message (HTTP 500)
- Migrate ErrRedeemFailed, ErrTwoFANotEnabled to model/errors.go
2026-04-12 17:39:00 +08:00
CaIon ba25ba88fe refactor(task): extract billing and polling logic from controller to service layer
Restructure the task relay system for better separation of concerns:
- Extract task billing into service/task_billing.go with unified settlement flow
- Move task polling loop from controller to service/task_polling.go (supports Suno + video platforms)
- Split RelayTask into fetch/submit paths with dedicated retry logic (taskSubmitWithRetry)
- Add TaskDto, TaskResponse generics, and FetchReq to dto/task.go
- Add taskcommon/helpers.go for shared task adaptor utilities
- Remove controller/task_video.go (logic consolidated into service layer)
- Update all task adaptors (ali, doubao, gemini, hailuo, jimeng, kling, sora, suno, vertex, vidu)
- Simplify frontend task logs to use new TaskDto response format
2026-02-22 16:00:27 +08:00
CaIon 4fdd12ac70 feat: Improve backend multilingual support 2026-02-12 14:29:56 +08:00
CaIon 5cf788f1bf refactor: enhance API security with read-only token authentication and improved rate limiting 2026-02-06 21:26:26 +08:00
CaIon a78c1c9be9 fix(i18n): prioritize user settings over Accept-Language header
The i18n middleware runs before UserAuth, so user settings weren't
available when language was detected. Now GetLangFromContext checks
user settings first (set by UserAuth) before falling back to the
language set by middleware or Accept-Language header.
2026-02-05 00:37:18 +08:00
CaIon b311d482e3 fix: update abortWithOpenAiMessage function to use types.ErrorCode 2026-01-19 17:35:28 +08:00
Hackerxiao 815bc61c67 Merge branch 'QuantumNous:main' into main 2025-12-30 11:44:15 +08:00
Seefs 7e1ad4bdff fix: 支持小写bearer和Bearer后带多个空格 && 修复 WSS预扣费错误提取key的问题 2025-12-24 15:52:56 +08:00
CaIon 692b5ff5ac feat(auth): refactor IP restriction handling to use clearer variable naming 2025-12-15 20:13:09 +08:00
CaIon 947a763a1a feat(auth): enhance IP restriction handling with CIDR support 2025-12-15 17:24:09 +08:00
CaIon 6175f254a2 refactor(channel_select): enhance retry logic and context key usage for channel selection 2025-12-13 16:43:38 +08:00
CaIon e0a79e853d refactor(auth): replace direct token group setting with context key retrieval 2025-12-13 01:38:12 +08:00
CaIon c87deaa7d9 feat(token): add cross-group retry option for token processing 2025-12-12 17:59:21 +08:00
hackerxiao 8257438499 feat: 支持仅使用x-api-key获取anthropic格式的模型列表 注释增加 2025-12-12 17:27:24 +08:00
hackerxiao f9c2e1fbf2 feat: 支持仅使用x-api-key获取anthropic格式的模型列表 2025-12-12 16:53:10 +08:00
CaIon 6aec088693 feat: add special user usable group setting 2025-10-28 23:25:43 +08:00
Seefs 5010f2d004 format: package name -> github.com/QuantumNous/new-api (#2017) 2025-10-11 15:30:09 +08:00
CaIon 893104a173 refactor: move anthropicKey retrieval to improve authorization handling 2025-08-15 16:08:55 +08:00
CaIon b850f94139 fix(auth): refine authorization header setting for messages endpoint #1575 2025-08-12 20:42:44 +08:00
nekohy 4cf1ffa801 feat: Enhance model listing and retrieval with support for Anthropic and Gemini models; refactor routes for better API key handling 2025-08-10 11:44:38 +08:00
Xyfacai 15c11bfe51 refactor: 调整模型匹配 2025-08-06 20:09:22 +08:00
feitianbubu d10c7a3548 fix: playground chat vip group 2025-07-24 09:38:00 +08:00
CaIon c773584ecd fix: 修复playground优先级失效 2025-07-17 22:26:38 +08:00
feitianbubu 79522d7688 fix: playground chat 2025-07-16 23:47:59 +08:00
CaIon cf11a22c3a 🔧 refactor(auth, channel, context): improve context setup and validation for multi-key channels 2025-07-06 12:37:56 +08:00
CaIon 04d525e317 🚀 feat(auth): support new model API paths in authentication and routing
- Updated TokenAuth middleware to handle requests for both `/v1beta/models/` and `/v1/models/`.
- Adjusted distributor middleware to recognize the new model path.
- Enhanced relay mode determination to include the new model path.
- Added route for handling POST requests to `/models/*path`.

These changes ensure compatibility with the new model API structure, improving the overall routing and authentication flow.
2025-06-25 00:19:38 +08:00
RedwindA 5e88e76001 feat: 支持从 x-goog-api-key header 中获取授权密钥 2025-06-04 15:41:25 +08:00
creamlike1024 75d859dce2 gemini text generation 2025-05-26 13:34:41 +08:00
1808837298@qq.com 78fc3a191c feat: claude relay 2025-03-12 21:31:46 +08:00
1808837298@qq.com d04d78a116 refactor: Enhance user context and quota management
- Add new context keys for user-related information
- Modify user cache and authentication middleware to populate context
- Refactor quota and notification services to use context-based user data
- Remove redundant database queries by leveraging context information
- Update various components to use new context-based user retrieval methods
2025-02-25 20:56:16 +08:00
1808837298@qq.com 530e846ac1 refactor: access_token auth 2025-01-05 22:08:23 +08:00
CalciumIon 966cdc1f7f refactor: user cache logic 2024-12-29 16:50:26 +08:00
CalciumIon c0c9b1f670 fix: realtime 2024-11-30 23:32:42 +08:00
1808837298@qq.com 9e4133a890 feat: realtime
(cherry picked from commit a5529df3e1a4c08a120e8c05203a7d885b0fe8d8)
2024-11-05 19:24:14 +08:00
1808837298@qq.com 411bbac036 feat: Playground相关接口禁用AccessToken 2024-09-26 01:49:35 +08:00
1808837298@qq.com 07fa9205cb feat: playground 2024-09-26 00:59:09 +08:00
1808837298@qq.com a50d2e6836 fix: error user role 2024-09-24 17:49:57 +08:00
CalciumIon 4a02eb1b7f feat: 令牌分组 2024-09-18 05:19:49 +08:00
CalciumIon 6d2948d684 feat: 添加令牌ip白名单功能 2024-09-17 20:49:51 +08:00
CalciumIon 165f29ade5 fix bug 2024-08-07 02:50:22 +08:00
CalciumIon cba830e544 feat: log user id 2024-08-04 14:35:16 +08:00
CalciumIon 28397c5d82 fix: 修复nginx缓存导致串用户问题 2024-07-19 13:39:05 +08:00
CaIon 97acc9e5c4 feat: add pricing page 2024-05-13 23:02:35 +08:00
CaIon fb992eeeac feat: 本地重试 2024-04-04 16:35:44 +08:00
CaIon 5659e5720f feat: 将操作拆分成单独的模型 2024-03-13 21:19:48 +08:00
CaIon 259c7fcdb0 feat: 初步兼容midjourney-proxy-plus 2024-03-13 15:37:01 +08:00
CaIon d72d8852cd fix: 完善令牌预扣费逻辑 2024-01-11 14:12:48 +08:00
CaIon ac78d4ba98 fix: 修复高并发下,高额度用户使用低额度令牌没有预扣费的问题 2024-01-10 14:23:23 +08:00
CaIon 8d9e04427b feat: 可设置令牌能调用的模型 2024-01-08 16:25:17 +08:00
CaIon 3b0b139c49 修复无法指定渠道id的问题 2023-12-14 16:43:20 +08:00