- [Web/Docker Mode OAuth Flow Fixes, State Tearing Protection, and Synchronous Exchange Feedback] (Fixes #3802, PR #3803, PR #3805, Thanks to @dandelion-promise520, @cubelikeplayDaniel):
- State Tearing & Duplicate Prepare Prevention: Optimized
handleOAuthWebinAddAccountDialogto prioritize reusing already prepared authorization URLs rather than re-triggeringprepare_oauth_urlupon clicking "Start OAuth"; added idempotent state reuse in backendprepare_oauth_flow_manually(returning existing URLs for identical client and redirect_uri), completely eliminating state overrides that caused callback codes to drop into cancelled channels. (Fixes #3802, PR #3803, Thanks to @dandelion-promise520, @cubelikeplayDaniel) - Built-in Client Loopback Fallback Guard (PR #3803): Added an
is_builtin_oauth_clientguard inresolve_oauth_redirect_urithat enforceshttp://localhost:<port>/auth/callbackfor the default built-in Google client even ifABV_PUBLIC_URLis set, completely avoiding upstream Google 400redirect_uri_mismatcherrors caused by unauthorized custom domains. (PR #3803, Thanks to @cubelikeplayDaniel) - Active Flow Cleanup on Exchange Failure (PR #3805): Added explicit
cancel_oauth_flow()calls upon exchange errors in bothsubmit_oauth_codeand HTTPhandle_oauth_callback, immediately freeing the global single-flow state when Google returnsinvalid_grantor expired codes; additionally clears the frontendoauthUrlcache upon submission error, completely eliminating stale flow state reuse and retry deadlocks. (PR #3805, Thanks to @cubelikeplayDaniel) - Bi-directional CSRF Fallback & Resilient Manual Input Parsing (PR #3803, PR #3805): Automatically extracts and forwards the original
statefromoauthUrlas a fallback when submitting manual codes in the frontend, preventing CSRF verification bypasses on bare code inputs; upgradedparse_manual_oauth_inputto reliably handle full URLs, schemelesslocalhost:<port>/...addresses,%2Fencoded strings, raw codes, and upstreamerror=access_deniedcallbacks. (Fixes #3802, PR #3803, PR #3805, Thanks to @dandelion-promise520, @cubelikeplayDaniel) - Client Key Preservation & Account Pool Sync: Replaced the detached background
tokio::spawntask in Web mode; manual code submissions and web callbacks now strictly preserve and forward the boundclient_keytoexchange_code_with_client, accompanied by activetoken_manager.load_accounts()reloading on callback, eliminating upstreaminvalid_grant: Bad Requesterrors caused by client mismatch. (Fixes #3802, PR #3803, Thanks to @dandelion-promise520, @cubelikeplayDaniel) - Headless/Docker Deployment Contextual Guidance & Action Guards: Added a clear contextual callout above the manual code input in Web mode explaining that browser connection refusal upon redirecting to
localhostis normal Google Desktop OAuth behavior, guiding remote users to copy and paste the full callback URL from the address bar; restricted the "I have authorized, continue" button to desktop mode to prevent Web UI confusion. (Fixes #3802, PR #3803, Thanks to @dandelion-promise520, @cubelikeplayDaniel)
- State Tearing & Duplicate Prepare Prevention: Optimized
- [Web/Docker 模式 OAuth 链路修复、状态防撕裂与回填同步闭环] (Fixes #3802, PR #3803, PR #3805, Thanks to @dandelion-promise520, @cubelikeplayDaniel):
- 消除前端重复 Prepare 与状态撕裂: 优化
AddAccountDialog中handleOAuthWeb逻辑,优先复用已生成的授权 URL,禁止点击「开始授权」时二次触发prepare_oauth_url;后端prepare_oauth_flow_manually增加状态幂等复用检查(同 client 与 redirect_uri 直接返回现有 URL),彻底解决双重请求导致后台全局 Flow 状态被重置覆盖、回调 code 掉入废弃通道的硬伤。(Fixes #3802, PR #3803, Thanks to @dandelion-promise520, @cubelikeplayDaniel) - 内置客户端防重定向失配拦截 (PR #3803): 在
resolve_oauth_redirect_uri中增加is_builtin_oauth_client环回回退防御,当使用默认内置 Google OAuth 凭据时,即使用户配置了ABV_PUBLIC_URL也强制使用http://localhost:<port>/auth/callback,彻底规避因公网/局域网域名未在上游控制台注册而触发的 Google 400redirect_uri_mismatch阻断。(PR #3803, Thanks to @cubelikeplayDaniel) - 换码失败主动清理脏状态闭环 (PR #3805): 在手动换码
submit_oauth_code及 HTTP 回调handle_oauth_callback的兑换异常分支中补充主动调用cancel_oauth_flow(),当 Google 报invalid_grant或 Code 过期时立即释放全局单例 Flow 状态;前端提交失败时自动清空本地oauthUrl缓存,彻底杜绝脏状态残留导致用户重试时因状态复用死锁。(PR #3805, Thanks to @cubelikeplayDaniel) - 手动回填 CSRF 双向核对与弹性解析 (PR #3803, PR #3805): 前端提交手动回填时,自动从预生成的
oauthUrl中解析原始state作为fallbackState传给后端,避免仅回填裸 Code 时因丢失 state 导致 CSRF 防护被跳过;升级parse_manual_oauth_input智能解析引擎,全面兼容完整 URL、无 scheme 域名(localhost:8045/...)、已编码%2F与裸 Code,并拦截上游error=access_denied等拒绝响应。(Fixes #3802, PR #3803, PR #3805, Thanks to @dandelion-promise520, @cubelikeplayDaniel) - Web 兑换透传客户端凭据与号池实时同步: 移除原 Web 模式后台游离且丢弃了 client 的
tokio::spawn异步任务;手动提交以及 Web 回调统一通过 flow 绑定的client_key调用exchange_code_with_client进行兑换,并在回调成功后主动调用token_manager.load_accounts()刷新内存与文件,彻底消除因客户端不匹配导致 Google 上游报invalid_grant: Bad Request的缺陷。(Fixes #3802, PR #3803, Thanks to @dandelion-promise520, @cubelikeplayDaniel) - 无头/Docker 远程部署交互与按键守护: 在 Web 模式手动回填输入框上方新增上下文提示,明确解释因 Google Desktop OAuth 规范限制,授权后跳转至
localhost显示连接拒绝属正常安全行为,引导用户直接复制地址栏完整 URL 粘贴提交;限制「我已授权,继续」按键仅在桌面端可用,避免 Web 模式下点击造成混淆。(Fixes #3802, PR #3803, Thanks to @dandelion-promise520, @cubelikeplayDaniel)
- 消除前端重复 Prepare 与状态撕裂: 优化
Full Changelog: v5.0.2-beta.4...v5.0.2-beta.5