Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the root HTML endpoint (GET /) by stripping access_token from the query string via a redirect after successful authentication, reducing the chance the plaintext token is leaked (e.g., via history or referrers).
Changes:
- Add a 303 redirect on
/whenaccess_tokenis present, redirecting to the same path with the token removed. - Add HTML response security headers (
Referrer-Policy: no-referrer,X-Content-Type-Options: nosniff) to both the redirect and the final HTML response. - Add endpoint tests covering token stripping, parameter preservation, invalid-token behavior, and the new headers.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
marimo/_server/api/endpoints/assets.py |
Implements access-token stripping redirect for / and applies HTML security headers. |
tests/_server/api/endpoints/test_assets.py |
Adds regression tests validating redirect behavior, header presence, and invalid-token handling. |
Two test-side touchpoints hit `/?access_token=...` and broke when the server started 303-redirecting to strip the token: - `_try_fetch` used `urllib.request.urlopen`, which follows redirects but does not preserve cookies. Swap to an `HTTPCookieProcessor`-backed opener so the session cookie set on the redirect response is replayed on the follow-up GET and the client lands on the authenticated page instead of the login screen. - `test_auth_by_query` asserted a direct 200 with `Set-Cookie`. It now explicitly does not follow the redirect, asserts the 303 + Location + Set-Cookie on the redirect response, and then verifies that the cookie authenticates the follow-up request.
akshayka
previously approved these changes
Apr 13, 2026
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.
Defense in depth for the edit-mode
access_token. Previously the token stayed inwindow.location.searchuntil the frontend'scleanupAuthQueryParamsran./route, when the query param is still present (auth has already validated it and promoted it to a session cookie), 303 redirect to the same URL with the token removed. The Set-Cookie rides the redirect, so the browser lands on a clean authenticated URL before any notebook-controlled content is parsed.Referrer-Policy: no-referrerandX-Content-Type-Options: nosniffon HTML page responses to block Referer leakage and MIME sniffing.