Commit Graph
8336 Commits
Author SHA1 Message Date
Wesley Liddick b9d6ff5ca2 Merge pull request #8504 from feeeei/feat/registration-email-blacklist
feat(auth): 注册邮箱精确黑名单,保存时可批量禁用命中的已注册用户
2026-11-04 21:01:00 +08:00
feeeei 721dfb282e feat(auth): 注册邮箱精确黑名单,保存时可批量禁用命中的已注册用户
- 系统设置 → 注册设置新增「邮箱黑名单(精确匹配)」,弹窗编辑、批量粘贴,上限 20000 条,
  名单存于 settings 键 registration_email_blacklist,由专用接口整体读写;运行时读 60s TTL
  进程内缓存,保存后本实例立即生效
- 按收件箱身份匹配(复用 NormalizeEmailForAliasDedup):Gmail 点号、googlemail.com 与 +后缀
  变体视为同一邮箱
- 邮箱注册、发验证码、第三方登录补建账号、绑定/换绑邮箱命中时返回 EMAIL_BLOCKED;
  已验证邮箱的 OAuth 登录只在新建账号时拦截,已有账号是否可用由账号状态决定
- 保存后对新增项查找仍启用的普通用户并弹窗确认批量禁用(跳过管理员、已禁用与已删除用户),
  与单个禁用一样在同一事务内吊销 MCP 授权,禁用后清理认证缓存;也可随时对整份名单手动检查
2026-11-04 17:52:05 +08:00
Wesley Liddick 6f92090d7f Merge pull request #8462 from feeeei/feat/openai-image-size-tier-routing
feat(openai): 生图账号按 1K/2K/4K 尺寸档位分流
2026-11-04 17:11:58 +08:00
Wesley Liddick ee74473e03 Merge pull request #8499 from feeeei/fix/openai-passthrough-instructions-echo
fix(openai): 透传放行空 instructions,响应回显按客户端原值还原
2026-11-04 17:11:47 +08:00
Wesley Liddick e320a1500b Merge pull request #8318 from wucm667/fix/issue-8313-antigravity-system-identity
fix(antigravity): neutralize stale system identities on forwarding
2026-11-04 17:11:35 +08:00
Wesley Liddick 393167ea9a Merge pull request #8436 from feeeei/fix/usage-export-rate-limit
fix(usage): 用户导出 CSV 每页取 1000 条,遇面板限流 429 按 Retry-After 等待后重试
2026-11-04 17:11:23 +08:00
Wesley Liddick ccc2c161b5 Merge pull request #8503 from wucm667/fix/issue-8502-kimi-concurrency-cooldown
fix(kimi): use short cooldown for concurrency-limit 403
2026-11-04 17:11:12 +08:00
Wesley Liddick 45b51a8ac4 Merge pull request #8465 from wucm667/fix/issue-8461-grok-message-input
fix(grok): normalize delegated message input for Responses
2026-11-04 17:11:00 +08:00
wucm667 9e4c03d2fe fix(usage): reconcile prompt totals across cache-only updates 2026-11-04 09:08:54 +08:00
wucm667 17772947bd fix(kimi): use short cooldown for concurrency-limit 403 2026-11-04 00:43:51 +08:00
feeeei 6b565e45a6 fix(openai): 生图尺寸溢出选号后按首轮前的绑定处理会话粘性
未指定尺寸的生图请求逐层选号时:

- 较早轮次只拿到排队结果后,后续轮次选号不写会话粘性绑定;
- 溢出轮次抢到槽位时,会话仍绑定在首轮选号前的账号上则保留该绑定,
  否则(首轮前没有绑定,或绑定在选号中被清除、改写)绑定实际服务的账号;
- 各轮都只能排队时,绑定保持首轮选号后的状态。

旧调度器顺序模式在抢槽前写绑定,此前会让首轮前没有可用绑定的会话在溢出后仍绑定在排队账号上。
2026-11-03 23:56:39 +08:00
feeeei a699c2baed fix(openai): 透传放行空 instructions,响应回显按客户端原值还原
- OAuth 透传不再对 codex 模型的空串、空白或非字符串 instructions 本地返回 403,原样转发给上游(官方 Codex 接口已不要求 instructions 必传)。
- 网关补写、追加或搬运 instructions 后,response.instructions 回显按客户端请求里的原始取值还原,客户端未传时还原为 null;覆盖原生与透传两条 HTTP 路径的流式、非流式与 SSE 转 JSON 出口。还原值压缩成单行,写回 SSE data 行不会拆帧。
2026-11-03 23:01:12 +08:00
Feei e97a48d84b fix: GPT-5.5已不提供服务,默认导出模型改为GPT5.6-SOL 2026-11-03 15:35:48 +08:00
feeeei e452e41e40 feat(openai): 生图账号按 1K/2K/4K 尺寸档位分流
账号 extra 新增 openai_image_size_tiers,限定账号承接的生图尺寸档位;档位口径与
计费 ClassifyImageBillingTier 一致(最长边 ≤1024=1K、≤2048=2K、更大=4K)。
缺省、空列表或三档齐全表示不限,存量账号行为不变。

- 请求尺寸可识别:只调度到允许该档位的账号,切号也只在这些账号之间进行。
- 未传 size / auto / 无法识别:不过滤,按偏好层级逐层选号——不限档位 → 允许 4K →
  允许 2K → 仅 1K;跳过没有账号的层级;较早层级只能排队时继续尝试后续层级,都抢不到
  槽位时返回最早的排队结果,且溢出选中的账号不改写会话已有的粘性绑定;会话粘性与
  previous_response_id 绑定的账号不受偏好约束。
- 档位轮次包在代理隔离 fail-open 之内:先不绕过隔离跑完全部档位,再整体绕过重跑。
- 覆盖 /v1/images/generations、/v1/images/edits(含异步图片任务)与 /v1/responses
  显式 image_generation 工具(tools[].size);判定挂在高级调度与旧调度/DB 复检的共用
  兼容检查上;调度快照 extra 白名单加入该键。
- 分组内持久可调度、支持该模型且具备所需能力的账号都不允许该档位时返回 400
  invalid_request_error,临时不可用仍为 503。
- 测试连接:受限账号按最低允许档位发送代表尺寸(1024x1024 / 1536x1024 / 3840x2160)。
- 前端:创建/编辑账号弹窗(OpenAI 全部类型)与批量编辑加入档位多选,至少保留一档;
  批量编辑全选时提交空列表表示不限。
2026-11-03 13:18:50 +08:00
Wesley Liddick 4a4a83ee5e Merge pull request #8476 from lyen1688/fix/admin-key-permissions-8473
完善管理员 API Key 权限并新增需确认的全权兼容模式
2026-11-02 11:17:44 +08:00
wucm667 bcb0512132 fix(billing): account for unclassified cache creation tokens and TTL overrides 2026-11-02 09:16:06 +08:00
wucm667 7b879c56a6 chore(deps): update follow-redirects security patch 2026-11-02 09:16:06 +08:00
lyen1688 b0db521ceb 修复权限国际化编码的 ES2020 类型兼容错误 2026-11-02 00:19:57 +08:00
lyen1688 ff04296510 补齐管理员密钥中英文权限展示并修复依赖安全扫描 2026-11-02 00:11:17 +08:00
lyen1688 194d69e636 完善管理员密钥权限并新增需确认的全权兼容模式 2026-11-01 23:52:35 +08:00
qsy4 f10a45c030 fix(auth): stop reporting client disconnects and malformed keys as 500
Problem: when GetByKey fails with anything other than not-found or
overloaded, the API key middlewares answer 500 "Failed to validate API
key" without logging the cause. Two client-side conditions end up there:

- The client goes away while the key is being looked up (connection
  closed after the body was sent, or an HTTP/2 stream reset). net/http
  cancels the request context, the cache/DB lookup returns
  context.Canceled, and a pure client disconnect is recorded as an
  internal server error. A key that is not in the 15 s L1 cache always
  reaches Redis/Postgres, so infrequent clients hit this regularly.
- A key that is not valid UTF-8. Postgres rejects the parameter
  (invalid byte sequence, SQLSTATE 22021), which surfaces as 500 instead
  of 401. Generated and custom keys are always ASCII, so such a key can
  never match.

Fix: GetByKey treats non-UTF-8 keys as not found before any cache or DB
access. Both middlewares (OpenAI/Anthropic and Google) end the request
with 499 when the request context is already done, which the ops error
logger already skips as a client-closed request; any other lookup error
is now logged before the 500.

Test: api_key_auth_test.go drives both middlewares with a lookup that is
cancelled mid-flight (499) and with a plain repository error (500), and
sends a non-UTF-8 x-api-key (401). api_key_service_cache_test.go checks
that a non-UTF-8 key never reaches the repository. All three fail
without the fix.
2026-11-01 00:26:34 -07:00
wucm667 9e8913876f Merge remote-tracking branch 'upstream/main' into HEAD 2026-11-01 09:44:39 +08:00
wucm667 522f1fb999 fix(grok): normalize delegated message input for Responses 2026-10-31 23:49:02 +08:00
40d9c0964b fix(openai): apply Codex fingerprint convergence in the WebSocket HTTP bridge
proxyOpenAIWSHTTPBridgeTurn built its upstream request without staging the
converged Codex fingerprint IDs, unlike Forward and forwardOpenAIPassthrough.
The bridge therefore sent different device-fingerprint headers than the HTTP
paths for the same account, and when the client sent no prompt_cache_key the
request carried no session_id at all, so upstream prompt-cache routing was
effectively random and multi-turn requests rarely hit the cache.

Stage the IDs (and rewrite client_metadata) the same way
forwardOpenAIPassthrough does, clearing any stale IDs first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
2026-10-31 06:38:40 -07:00
cyh 3425ba3663 fix(gateway): bound stalled request body reads and classify read failures
Gateway handlers such as Anthropic /v1/messages read the whole request body
before they know the model or account. The HTTP server sets no ReadTimeout
(large bodies may legitimately take long), so a stalled upload held the
handler until the client gave up, and every read failure then surfaced as a
generic 400 "Failed to read request body" with no diagnostics.

- Add server.request_body_idle_timeout (default 60s, 0 disables). A body
  read that receives no bytes for that long fails with 408. Each Read re-arms
  the deadline, so total upload time is not limited and handler pauses are
  not counted. HTTP/2 deadlines are armed only during a Read; HTTP/1 keeps
  one armed while the body is unfinished so net/http's own drain of an
  unread body cannot hang an early error response.
- Classify body read failures in the shared reader: read timeout (408),
  client disconnect (499), truncated body, decode errors and size limit.
  Other failures keep the stable 400 message. Map 408 to DEADLINE_EXCEEDED
  in Google-format errors.
- Log payload-free diagnostics for every gateway and middleware body read
  failure: kind, protocol, declared length, encoding, bytes received and
  read duration.
2026-10-31 11:45:55 +08:00
folltoshe c476edbf40 fix(openai): skip responses probe when routing mode is forced 2026-10-30 22:45:35 +08:00
mordekasiser c35418032b fix(antigravity): preserve direct Gemini streaming responses 2026-10-30 03:43:16 -07:00
wangjunwei fa6f06510b fix(openai): let error passthrough rules override the built-in body-limit 413
handleFailoverExhausted returned a fixed 413 for
IsOpenAIRequestBodyTooLarge() before reaching the generic error-passthrough
rule lookup further down, so a rule configured with error_codes [413] could
never match on this path. The service layer already returns the same
failover sentinel ahead of applyErrorPassthroughRule, so both layers
short-circuit and the rule vocabulary silently excludes 413.

Extract the existing rule application into
applyOpenAIFailoverPassthroughRule and call it first inside the body-limit
branch (and reuse it for the generic branch). Failover on 413 is left
intact: different accounts can front proxies with different body limits, so
switching may still succeed. The rule only decides the client-facing
response once failover is exhausted.

This matters for clients that treat 413 as retryable. Codex CLI maps a
non-2xx HTTP status to CodexErr::UnexpectedStatus, whose is_retryable()
returns true, and retries the sampling request up to stream_max_retries
(default 5) times. When the payload can never fit, every retry is wasted
work, and an operator has no supported way to signal "do not retry". Mapping
the same upstream 413 to 400 makes Codex map it to InvalidRequest, which is
not retryable, so it fails fast.

Tests cover the override on both unary and started-stream paths, the
unchanged built-in 413 when no rule matches, and skip_monitoring.
2026-10-30 15:19:54 +08:00
feeeei e47abd8f9b fix(usage): 用户导出 CSV 每页取 1000 条,遇面板限流 429 按 Retry-After 等待后重试
用户使用记录导出按 100 条/页连续请求 GET /api/v1/usage,该路由计入按用户的
重查询限流(默认 heavy_rpm=60,固定 60 秒窗口)。数据量超过约 5,000 行时,
导出在第 50~60 页收到 429,任一页失败即整体报「导出失败」。

- 导出页大小改为 1000(后端分页上限),请求数降为原来的 1/10。
- API 客户端结构化错误携带 retry_after_seconds(解析整数秒的 Retry-After)。
- 导出遇 429 时提示并按 Retry-After 等待(读不到时按 60 秒,夹在 1~60 秒)
  后重试同一页,每页最多重试 3 次。
2026-10-30 13:53:18 +08:00
111pointer111 890120120d fix(openai): 修复 GPT Image 账号生图测试参数 2026-10-30 12:54:52 +08:00
shaw d851a38477 fix(frontend): upgrade vue-i18n to v11 and patch decode-uri-component
Fixes frontend-security on main for two new high advisories:
- GHSA-83rm-6c8r-g728 (vue-i18n / @intlify/* srcdoc XSS): v9 and v10
  are end of life and will not be patched, so move vue-i18n and
  @intlify/message-compiler to 11.4.16.
- GHSA-qr28-fpjm-wq7f (decode-uri-component quadratic DoS): add a
  pnpm override to >=0.5.1; its API and types are unchanged.

vue-i18n 11 requires Node >= 22, so CI and release workflows move from
Node 20 to Node 24, matching the Docker build image.

JIT message compilation is always on since v10, so the obsolete
__INTLIFY_JIT_COMPILATION__ define is removed; the build still has no
new Function. SubscriptionPlanCard spec asserted raw keys that v9's
runtime build returned; it now asserts the rendered test messages.
2026-10-30 10:44:47 +08:00
Wesley Liddick 7386bc6ae0 Merge pull request #8389 from StarryKira/codex/management-mcp
feat: add OAuth-authenticated management MCP
2026-10-30 09:49:16 +08:00
shaw fb22c92126 fix(backend): bump MCP go-sdk to v1.4.1 for GO-2026-4770/4773
go-sdk v1.4.1 fixes GO-2026-4773 (cross-site tool execution) and
GO-2026-4770 (null Unicode JSON parsing), which fail govulncheck.

v1.4.1 also adds transport-level cross-origin and Content-Type checks
that would reject requests Authenticate already accepts:
- trust the same allowed origins in the SDK's CrossOriginProtection so
  CORS-allowlisted browser clients are not refused with 403;
- accept application/json with parameters (e.g. charset) by normalizing
  the header, while still refusing non-JSON bodies with 415.
2026-10-30 09:36:53 +08:00
shaw f532737de2 Merge branch 'main' into codex/management-mcp
# Conflicts:
#	backend/go.mod
#	backend/go.sum
2026-10-30 09:21:24 +08:00
lkon aae31c7438 fix(gemini): preserve tool media in native function responses 2026-10-30 09:06:51 +08:00
lkon 2d6b64a18e fix(responses): preserve message content fields in completed responses 2026-10-30 09:06:51 +08:00
harukaandClaude Opus 5.5 b3eb7194c2 fix(frontend): truncate long MCP client IDs
Signed client IDs are now about 200 characters. Show them on one line on
the consent page and in the connection list, with the full value in the
title. The random part leads, so truncated IDs still differ.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 14:46:08 -04:00
harukaandClaude Opus 5.5 575dd9bc2b fix(backend): make MCP client registration stateless
Registration was capped at 1000 pending clients site-wide while the limit
per IP was 10 per minute, so one address could exhaust the cap and block
every new MCP client.

- Issue client IDs as HMAC-signed tokens carrying the client name,
  redirect URI digests and grant types. Registration writes nothing;
  rows are created only when a user approves a client, so there is no
  shared capacity to exhaust.
- Persist the signing key in security_secrets via the existing
  get-or-create helper, cached lock-free, so instances share it.
- Drop mcp_oauth_clients from migration 249 and keep the client name on
  each grant. Prune expired grants on authorization, before the owner
  row is locked.
- Fix an unchecked type assertion in managementmcp tests flagged by
  golangci-lint v2.14.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 14:46:08 -04:00
Kayokoi 2106081510 fix(anthropic): omit beta query for Cloudflare REST messages 2026-10-29 07:06:40 -07:00
Bao Le 0b535b5c07 fix(antigravity): Gemini 原生请求的 responseJsonSchema 改写为 responseSchema
Antigravity 上游 (v1internal) 接受 generationConfig.responseJsonSchema 字段但静默忽略,
返回普通文本而非 JSON;只有 responseSchema 能触发结构化输出。@ai-sdk/google >= 4.0.70
等客户端只发送 responseJsonSchema,导致经网关的结构化输出全部失效。

cleanGeminiRequest 现在把 responseJsonSchema / response_json_schema 改写为 responseSchema,
并复用 CleanJSONSchema 清理(去掉 $schema、additionalProperties,约束迁移到 description)。
已有 responseSchema 时以其为准;没有 schema 的请求保持原样。
2026-10-29 12:41:57 +07:00
Wesley Liddick a3298b46eb Merge pull request #7979 from ShuminFu/fix/oauth-passthrough-non-stream-7978
fix(openai): return JSON for non-stream OAuth passthrough /v1/responses
2026-10-28 21:41:00 +08:00
harukaandClaude Opus 5.5 8a34f1ecf3 fix(frontend): use the MCP logo and hide MCP when disabled
- Replace the cube icon with the official MCP logo in the sidebar and on
  the MCP connection and consent pages.
- Show the MCP entry only when the deployment enables MCP (mcp_enabled).
- Explain that administrator write grants always need TOTP verification,
  and add MCP OAuth to the audit log auth-method filter.
- Remove the unreferenced screenshots and their .gitignore exceptions (L6).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 09:30:23 -04:00
harukaandClaude Opus 5.5 ee71c7f379 fix(backend): harden management MCP per review
- Reject JSON-RPC batches and non-object bodies before the SDK; return each
  tool result once as text and bound the encoded payload (H1).
- Enable MCP only when MCP_PUBLIC_URL is set; drop the frontend URL fallback
  and expose a read-only mcp_enabled public setting (M1).
- Expire never-authorized clients after 24h, cap pending registrations
  globally, aggregate MCP IP limits by IPv6 /64, and limit registration
  bodies to 4 KiB (M2).
- Revoke MCP grants with revoke-all-sessions and always require step-up for
  administrator write grants (M3).
- Rate limit /api/v1/mcp per IP before authentication and write last_used_at
  at most once per minute (M4).
- Persistently revoke grants when an account is disabled or demoted, derive
  result redaction from SensitiveCredentialKeys, allowlist browser sessions
  for step-up, audit every MCP read, reject invisible characters in
  client_name, and document site-root-only deployment (L1-L5, L7).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 09:30:23 -04:00
ShuminFuandSipengXie2024 4db8402b50 fix(openai): detect SSE body without Content-Type in OAuth passthrough non-stream
The ChatGPT OAuth upstream may answer with SSE but omit the Content-Type
header. Fall back to bodyHasSSEFraming for OAuth accounts in
handleNonStreamingResponsePassthrough, matching handleNonStreamingResponse,
and add a regression test covering both passthrough and non-passthrough.

Co-authored-by: SipengXie2024 <184713193+SipengXie2024@users.noreply.github.com>
2026-10-28 09:06:04 -04:00
github-actions[bot] a9240d5016 chore: sync VERSION to 0.2.19 [skip ci] 2026-10-28 10:16:21 +00:00
Wesley Liddick dece261536 Merge pull request #8373 from feeeei/fix/openai-models-cache-singleflight-recheck
fix(models): 模型列表刷新进入 singleflight 后复查缓存,避免并发冷启动重复请求上游
v0.2.19
2026-10-28 18:03:26 +08:00
Wesley Liddick 184193f01e Merge pull request #8369 from feeeei/fix/gemini-bound-cache-pool-retry
fix(gemini): 绑定显式缓存的请求在池模式上游网关账号上按配置同账号重试
2026-10-28 18:03:11 +08:00
Wesley Liddick 7311b865f3 Merge pull request #8287 from feeeei/feat/gemini-same-account-retries-config
feat(gemini): 同账号重试次数改为可配置 gateway.max_same_account_retries_gemini
2026-10-28 18:02:29 +08:00
Wesley Liddick bf02c1a6e0 Merge pull request #8395 from feeeei/fix/gemini-model-lists
fix(gemini): /v1beta/models 按分组声明的模型应答,并刷新 Gemini 默认模型列表
2026-10-28 17:42:12 +08:00
Wesley Liddick 8b3f33f28a Merge pull request #8390 from wc4440222/pr/fix-websearch-emulation-dimensions
fix(channels): 渠道保存不再覆盖 web_search_emulation 的平台维度
2026-10-28 17:41:29 +08:00