Add protected auth flow for remote web access#1362
Add protected auth flow for remote web access#1362lamhoangtung wants to merge 3 commits intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

What Changed
In built web mode,
--auth-tokennow protects both HTTP routes and WebSocket connections instead of only gating the socket handshake.Unauthorized browser requests now render a dedicated sign-in page. Tokenized links like
/?token=...are accepted once, stored in an auth cookie, and redirected to a clean URL without the token. This also adds form-based token entry, stale-cookie invalidation after token changes, origin checks for cookie-authenticated WebSocket upgrades, startup/browser-open handling for protected links, and docs/tests covering the remote access flow.Why
Previously, remote protection in web mode was incomplete: a token was required for the WebSocket connection, but the HTTP app surface was still reachable without authentication. That made the security model inconsistent and awkward for real remote access, especially on phones or shared links.
This change makes built web mode behave like users expect: the token gates access to the whole app, not just the live session channel. The tokenized-link-to-cookie flow keeps first-time access simple while removing the token from the URL after login and re-prompting cleanly when the token rotates.
Related issues:
UI Changes
This PR adds a dedicated protected sign-in page for built web mode.
Before:
After:
Checklist
Note
High Risk
Touches authentication for both HTTP routing and WebSocket upgrades in web mode; regressions could lock users out or unintentionally expose the UI if the new checks are incorrect.
Overview
In built web mode,
--auth-tokennow protects the full HTTP surface (not just the WebSocket handshake): unauthorized document requests return a new sign-in page, and non-document routes return401 Unauthorized.Introduces a token-to-cookie flow: visiting
/?token=...sets anHttpOnlyauth cookie and redirects to a clean URL, plusPOST /auth/loginfor manual token entry and stale-cookie invalidation when the server token changes.WebSocket upgrades in protected web mode accept either a query token or a valid auth cookie, with an added Origin/Host match requirement for cookie-authenticated upgrades. Startup behavior is updated to log/auto-open a tokenized share URL when protection is enabled (skipping tokenization in dev-url mode and keeping wildcard hosts opening on
localhost).Written by Cursor Bugbot for commit 822c094. This will update automatically on new commits. Configure here.
Note
Add protected auth flow for remote web access with token-based cookies and WebSocket gating
Unauthorized; valid token in query sets an auth cookie and redirects to a clean URL;POST /auth/loginaccepts a token form submission and sets the cookie.Originhost, rejecting stale or mismatched-origin cookies.Macroscope summarized 822c094.