Skip to content

Fix Auth0 token refresh + full logout (Auth0 + CILogon)#41

Merged
robmsmt merged 2 commits into
mainfrom
fix/auth-refresh-and-full-logout
Jun 12, 2026
Merged

Fix Auth0 token refresh + full logout (Auth0 + CILogon)#41
robmsmt merged 2 commits into
mainfrom
fix/auth-refresh-and-full-logout

Conversation

@robmsmt

@robmsmt robmsmt commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

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_ISSUER only. AUTH0_ISSUER is not VITE_-prefixed, so it isn't baked into the built server bundle — at runtime it only exists on process.env (from the deployment configmap). So once the access token expired, the refresh URL became undefined/oauth/token and getSession threw, producing "Error loading API key. Please sign out and sign in again."

Fix: use the same process.env.AUTH0_ISSUER fallback the rest of the file already uses (lines 32-34).

Found via the dev pod logs:

Error refreshing access token: TypeError: Failed to parse URL from undefined/oauth/token
    at async getSession

(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.

⚠️ Auth0 dashboard requirement: the app origin(s) must be in Allowed Logout URLs in the Auth0 application settings, or /v2/logout will error on return. Please confirm the prod + dev origins are listed.

Verification

  • npm run build passes (server bundle builds, logout import resolves).
  • Backend was confirmed healthy in dev (/v1/profile and /v1/profile/rotate both 200); this PR is frontend-only.

🤖 Generated with Claude Code

robmsmt and others added 2 commits June 12, 2026 18:18
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>
@robmsmt robmsmt requested a review from loleg June 12, 2026 16:22
@robmsmt robmsmt merged commit 4e760ea into main Jun 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant