Skip to content

feat: 新增 AUTH_RECOVERY 控制认证失效后的续签 - #182

Open
luvs01 wants to merge 1 commit into
Mag1cFall:mainfrom
luvs01:auth-recovery-opt-out
Open

luvs01 wants to merge 1 commit into
Mag1cFall:mainfrom
luvs01:auth-recovery-opt-out

Conversation

@luvs01

@luvs01 luvs01 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

改动 / Changes

  • 新增 AUTH_RECOVERY,默认 true,控制账户会话失效后的自动续签。开启时使用已保存的续签材料恢复认证并重放请求;关闭时将账户标记为需要重新登录,由用户在账户页完成登录。用于需要人工确认登录会话来源的部署。
  • DBSC 会话的主动刷新与人工登录、导入按现有生命周期执行。
  • 管理端保存设置时保留 .env 或环境变量中的取值,保存值与运行中配置不同时显示重启提示。
  • 同步中英文 README、示例配置和开发文档。

验证 / Verification

  • go test -mod=readonly -trimpath -vet=off ./cmd/... ./internal/...:覆盖自动续签开启与关闭、账户认证状态、双向重启提示、设置保存和内部保存值的 JSON 可见性。
  • Go vet、前端构建、Web typecheck 与 lint 通过。
  • 当前提交 260a729f 的检查结果:Checks。

@luvs01
luvs01 marked this pull request as ready for review November 16, 2026 17:38
@Mag1cFall

Copy link
Copy Markdown
Owner

Thanks for the PR, but i don’t quite get the scenario here, when would someone want the account to drop to re-login instead of renewing from the saved credentials? If a user imported the account with cookies and the auto renewal quietly swapped it into a Chrome import, that could be a problem, but i still don’t quite understand it.

luvs01 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — the cookie-import → Chrome-import case you mention is the concrete example I should have explained. My PR description was too vague.

In the recovery code at this PR's head, the path is:

  1. An account was imported with cookies and has no saved OAuth renewal material.
  2. Its session fails authentication, but the same email is also signed into local Chrome. Available accepts that Chrome account as a recovery source.
  3. Refresh constructs a Chrome source, calls importCurrentChromeState, and saves the imported authentication state before retrying.

That is a change of credential source, not a switch to a different Google account: the code checks the email, and also checks the Gaia ID when prior OAuth material exists. This is confirmed by reading the code; I am not reporting a newly reproduced end-to-end incident.

My use case is running independent local instances on two machines and explicitly managing how each account is authenticated. After a session is confirmed expired, I want the affected account to require my sign-in/re-import, rather than having a generation request automatically recover it from credentials available in that machine's Chrome profiles. I accept the interruption in exchange for that explicit decision.

The proposed flag defaults to true, preserving existing behavior. Setting it to false skips reactive recovery and uses the existing authentication-required confirmation path; proactive DBSC refresh and explicit sign-in/import remain unchanged. I do not have evidence that this reduces Google's blocking risk.

You are right that the current flag is broader than the cookie-to-Chrome case: it also disables reactive renewal from already saved material. A narrower policy controlling automatic Chrome-source fallback could address this specific use case while retaining same-source renewal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants