fix(webview): keep the browser's cookies on the websocket leg

The HTTP leg puts the server-held dsh credential in front of the browser's own
cookies; the upgrade leg replaced them with it. A managed dsh tab is trusted, so
its other cookies must survive there too. Filter the request the way the HTTP
leg does and merge the credential in front.

Order is the point: a `Cookie` header can name the same cookie twice, and the
first value is the one parsers keep, so appending the credential let a stale
browser copy of the same dsh cookie shadow the one the running process minted -
the tab would come back to the 401 this path exists to prevent. Both legs now
lead with it, and a route-level test asserts the bytes the upstream sees on the
upgrade, not only on the HTTP request.
This commit is contained in:
ArizeSky committed 2026-11-16 16:30:25 +08:00
1 parent 44a10cff39
commit 2a3496b7b3
6 files changed
+119 -22

No files matched your search

+4 -2
View File
@@ -316,8 +316,10 @@ privileged-commands grant `POST /api/deepseek/web` requires, and in multi-user m
only to the owner whose request started that process. A different owner's start
request restarts the server rather than reusing a cookie that is not theirs, which
is why the shared instance is effectively single-user at a time. On a trusted
managed tab the cookie is appended to whatever cookies dsh itself set in the
browser, rather than replacing them.
managed tab the cookie is sent ahead of whatever cookies dsh itself set in the
browser, rather than replacing them; leading matters because a `Cookie` header can
name the same cookie twice and the first value is the one the dashboard parses, so
a stale browser copy must not shadow the one the running process minted.
## 7. Docker and remote cases