feat(web): token-authenticated control.ashx upgrade (VS-32) #47
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/control-token-upgrade-vs-32"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
VS-32: Token-authenticated control channel upgrade (browser cross-origin)
Problem
/control.ashxauthenticated the WebSocket upgrade exclusively from themc_sessioncookie. A browser that logged in through vervain-apps holds its session as an HttpOnlyvervain_sessioncookie on its own origin and can never presentmc_sessioncross-origin, which blocked a direct persistent control connection (VAPP-14).Change
A single-use, 60 s control-upgrade token bound to the session's userid:
control_token::ControlTokenStore(in-memory, auto-GC, mirrorsOtpStore).mintissues an opaque base64-url token;consumeresolves and removes it (single-use), rejecting expired entries.authcookiecontrol action mints one and returns it as a newcontrolTokenfield alongside the existingcookie/rcookie.control_ws_handler: whenmc_sessionis absent, accept?auth=<token>, validate + consume it, and proceed with the resolved userid. The cookie path is unchanged; the token authenticates the upgrade only and the socket keeps today's session semantics.Acceptance criteria
authcookiereturns a control token alongside the existing cookies (controlTokenfield)?auth=token succeeds with the correct user identity; reused or expired tokens get 401tests/control_token.rs) plus store unit testsTests
cargo test -p meshcentral-webgreen: 5 newcontrol_tokenstore unit tests, updatedauthcookie_wire_shape, and a 4-case integration suite (token connect + identity, reuse 401, expiry 401, unknown-token 401, unchanged cookie path). Clippy clean.#VS-32