Fix Auth0 token refresh + full logout (Auth0 + CILogon)#41
Merged
Conversation
AUTH0_ISSUER is not VITE_-prefixed, so it is not baked into import.meta.env in the built server bundle. The refresh path used only import.meta.env, so the URL became "undefined/oauth/token" and getSession threw once the access token expired (breaking the API key page). Use the same process.env fallback the rest of auth.config.ts already uses. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Logout button used auth-astro's SignOut, which only clears the local app session cookie. The Auth0 (and upstream CILogon) session persisted, so the next "View API Key" silently re-authenticated without a login prompt. Logout now clears the local session, then redirects to Auth0 /v2/logout?federated, which ends the Auth0 session and federates logout to the upstream IdP (CILogon), forcing a real login next time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Two auth fixes found while testing the dev deployment of #39.
1. Auth0 token refresh broke the API-key page (
auth.config.ts)The refresh path built the token URL from
import.meta.env.AUTH0_ISSUERonly.AUTH0_ISSUERis notVITE_-prefixed, so it isn't baked into the built server bundle — at runtime it only exists onprocess.env(from the deployment configmap). So once the access token expired, the refresh URL becameundefined/oauth/tokenandgetSessionthrew, producing "Error loading API key. Please sign out and sign in again."Fix: use the same
process.env.AUTH0_ISSUERfallback the rest of the file already uses (lines 32-34).Found via the dev pod logs:
(Pre-existing bug, not introduced by #39 — it only surfaces on token refresh.)
2. Logout didn't end the Auth0 / CILogon session (
index.astro)The Logout button used auth-astro's
<SignOut>, which only clears the local app session cookie. The Auth0 session (and the upstream CILogon IdP session) persisted, so the next "View API Key" silently re-authenticated without a login prompt.Fix: Logout now clears the local session, then redirects to
https://$AUTH0_DOMAIN/v2/logout?federated&client_id=...&returnTo=<origin>, which ends the Auth0 session and federates logout to CILogon./v2/logoutwill error on return. Please confirm the prod + dev origins are listed.Verification
npm run buildpasses (server bundle builds, logout import resolves)./v1/profileand/v1/profile/rotateboth 200); this PR is frontend-only.🤖 Generated with Claude Code