Repository navigation
fix(terminal): 挂起会话上无 Cookie 的 view-link 读 grant 回「会话已挂起」而不是 403 - #3019
Merged
Merged
Conversation
唤醒分级不认 view-link API 签发的 central 读 grant,前门已验证并附 forward proof 的无 Cookie 请求被归为 none → 403。新增 view-grant:挂起会话回挂起页,其它无 worker 会话仍不唤醒(grant 钉着已不存在的 worker 代,唤醒后 worker 必拒)。
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 7, 2026 10:55
This was referenced Nov 7, 2026
|
🚀 Released in v3.59.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2341
症状
会话被 idle TTL 挂起后,经 Dashboard 前门打开的 view-link,在不带 Cookie 的请求上(如 iOS WebView 的 WebSocket 升级)得到 403「链接已失效」,而不是 503「会话已挂起」。
根因
这类请求的
?viewToken=是 view-link API 签发的 central 读 grant,前门确认 auth session 存活后只附x-botmux-terminal-viewforward proof。daemon 的classifyTerminalWakeCredential只认写 token、唤醒证明、Dashboard Cookie、control grant 头和活 worker / 卡片 view token,不认这种 grant,于是归为none→deny→ 403。修法
唤醒分级新增
view-grant:viewToken是签名 grant、forward proof 经verifyTerminalViewForward通过,且 grant 校验通过(本会话、未过期、scope: 'read'、audience: 'central',与 worker 接受条件一致)。suspended,回「会话已挂起」页;deny,与修复前一致。没有按 issue 建议归入
read-link:central grant 钉着签发时那一代 worker 的workerGeneration,而无 worker 时任何唤醒都会 fork 出新一代,worker 必然按 generation 不匹配拒绝。归入read-link会在普通无 worker 会话上白唤醒一次再 403,违反「只为 worker 会接受的请求唤醒」的不变量。worker 侧读/写授权判定不变。验证
test/terminal-wake-policy.test.ts:view-grant;缺 proof、proof 属于另一个 grant、别的会话、已过期、无 audience 的 loopback 读 grant →none;view-grant+ 挂起 →suspended,未挂起 →deny;变异验证:
terminal-wake-policy.ts时,上述 3 个用例变红(端到端为 403);相关 8 个测试文件(wake policy、terminal proxy、front proxy、dashboard-auth 等)199 个用例全绿;
bun run build通过。