Lower browser PKCE mint priority; HTTP-first by default.
Browser path is slow; only use it as fallback after HTTP mint fails unless cpa_prefer_browser_mint is explicitly enabled.
This commit is contained in:
1 parent
bf30d40c8b
commit
0417fa3218
3 files changed
+12
-9
No files matched your search
+7
-7
@@ -72,11 +72,11 @@ def _mint_tokens(
|
||||
log: Callable[[str], None],
|
||||
proxy: str | None,
|
||||
) -> dict[str, Any]:
|
||||
"""铸造策略(有 page 时优先浏览器,避免直连 auth.x.ai 卡超时):
|
||||
"""铸造策略(默认 HTTP 优先,浏览器作兜底,避免拖慢吞吐):
|
||||
|
||||
1. page+sso 且 cpa_prefer_browser_mint:直接浏览器 PKCE
|
||||
2. 否则 HTTP SSO→OAuth(curl_cffi,短超时)
|
||||
3. HTTP 失败且有 page:浏览器 PKCE
|
||||
1. 仅当 cpa_prefer_browser_mint=true 且有 page:先浏览器 PKCE
|
||||
2. HTTP SSO→OAuth(curl_cffi,短超时)— 默认主路径
|
||||
3. HTTP 失败且有 page + cpa_allow_browser_fallback:浏览器 PKCE
|
||||
4. 可选设备码(通常无 referrer,默认关)
|
||||
"""
|
||||
from oidc_mint.oauth_code import (
|
||||
@@ -90,13 +90,13 @@ def _mint_tokens(
|
||||
sso_token = normalize_sso_cookie(sso or "")
|
||||
prefer_sso = bool(cfg.get("cpa_prefer_sso_oauth", True))
|
||||
allow_browser = bool(cfg.get("cpa_allow_browser_fallback", True))
|
||||
# 有注册浏览器时默认先浏览器:直连/跨境对 auth.x.ai 经常 curl(28)/ReadTimeout
|
||||
prefer_browser = bool(cfg.get("cpa_prefer_browser_mint", True))
|
||||
# 默认 False:先 HTTP(快);浏览器只在 HTTP 失败时兜底
|
||||
prefer_browser = bool(cfg.get("cpa_prefer_browser_mint", False))
|
||||
allow_device = bool(cfg.get("cpa_allow_device_fallback", False))
|
||||
timeout = float(cfg.get("mint_timeout_sec", 300) or 300)
|
||||
require_ref = bool(cfg.get("cpa_require_referrer", True))
|
||||
http_err: Exception | None = None
|
||||
browser_timeout = min(timeout, float(cfg.get("cpa_browser_mint_timeout_sec", 120) or 120))
|
||||
browser_timeout = min(timeout, float(cfg.get("cpa_browser_mint_timeout_sec", 90) or 90))
|
||||
|
||||
def _browser_mint(reason: str) -> dict[str, Any]:
|
||||
log(f"[cpa] 浏览器 PKCE 铸造({reason})")
|
||||
|
||||
Reference in new issue
Block a user