Repository navigation
[web-console] Keep the OIDC code and state out of the referrer after login - #7912
Merged
Merged
Conversation
…login After the code exchange, the callback page went to `/` with a full page load while its URL still held `?code=...&state=...`. The new page got that URL as `document.referrer`, and the PostHog and ConceptualHQ scripts sent it to third parties as `referrer` and `$initial_referrer`. - Remove the query and fragment from the callback URL before the navigation, and navigate with `location.replace`. - Set `<meta name="referrer" content="strict-origin">`, so that pages of the console get only the origin as the referrer. - Do not start the analytics scripts on the callback page, whose URL holds the code and state. Also ignore the local `/.tmp/` scratch directory.
Contributor
|
LGTM
Gates: tests cover each part of the fix, the e2e test has no sleeps, and there are no deps, docs or breaking changes involved. I also checked that skipping analytics on the callback page does not lose the |
xiasongh
approved these changes
Nov 10, 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.
Problem
After the OIDC code exchange,
/auth/callback/page redirected the user to/(home page) while its URL still held?code=...&state=.... The new page got that URL asdocument.referrer. The PostHog and ConceptualHQ scripts sent it to third parties asreferrerand$initial_referrer.The code is single-use, PKCE-bound and already redeemed when it is sent, so it cannot be replayed. But authentication data must not go to analytics vendors.
Fix
leaveOidcCallback()removes the query and fragment withhistory.replaceState, then navigates withlocation.replace.src/lib/services/auth.ts, called fromsrc/routes/+layout.ts<meta name="referrer" content="strict-origin">, so that pages of the console get only the origin as the referrer. Referrers from other sites do not change, because the linking site's policy controls them.src/app.htmlinitializeConfigDependenciesinsrc/routes/+layout.tsThe PR also adds
/.tmp/to.gitignorefor local scratch files.Tests
auth.spec.tsisOidcCallbackPagematches only the callback path.layout.spec.ts/.tests/auth/oidcCallback.e2e.tsdocument.referreris the console origin.http://localhost:8095/auth/callback/?code=...&state=...Run locally against a manager with OIDC:
vitest --project server: 525 passedtest-e2e-auth: the new test,homeDemosandlogoutpassed. The 3signup.e2e.tstests failed locally in the same way on a build without this change, so the cause is the local setup. CI runs them on the Docker image.Not in this PR
$initial_person_info(localStorage and cookie) until they log out.