Skip to content

Commit a34562f

Browse files
robmsmtclaude
andauthored
Logout fixes: correct client_id + drop pointless ?federated (#42)
* Logout: use deployed AUTH0_CLIENT_ID/DOMAIN, not VITE_ vars The deployment configmap/secret expose AUTH0_CLIENT_ID and AUTH0_DOMAIN, not VITE_AUTH0_* (those are local-dev only). Reading the VITE_ vars would yield undefined at runtime, breaking the logout URL. Use the non-VITE vars (the same app the server authenticates with, so logout's client_id matches the session), with VITE_ as a local-dev fallback. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Drop ?federated from logout: CILogon has no end_session_endpoint CILogon's OIDC discovery exposes no end_session_endpoint, so Auth0 federated logout cannot end its session — ?federated only produced federated_logout_failed log noise. Plain Auth0 logout still clears the app + Auth0 session; the CILogon/institution SSO session cannot be cleared programmatically. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4e760ea commit a34562f

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

frontend/src/pages/index.astro

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,24 @@ const articles = (await getCollection("articles"))
2929
// instead of a Sign In button that would kick off the real Auth0 flow.
3030
const authBypass =
3131
(process.env.VITE_DEV_AUTH_BYPASS || import.meta.env.VITE_DEV_AUTH_BYPASS) === 'true';
32-
// Auth0 tenant for the logout redirect (clears the Auth0 + upstream CILogon
33-
// session, not just the local app cookie). process.env wins for SSR runtime.
32+
// Auth0 config for the logout redirect (clears the local app cookie + the
33+
// Auth0 session; CILogon's IdP session can't be cleared, see the logout
34+
// handler below). Use the SAME app the server logs in with — AUTH0_CLIENT_ID /
35+
// AUTH0_DOMAIN from the deployment configmap/secret — so logout's client_id
36+
// matches the session. These are not VITE_-prefixed, so at runtime they only
37+
// exist on process.env (SSR); VITE_ vars are a local-dev fallback.
3438
const auth0Domain =
35-
process.env.VITE_AUTH0_DOMAIN || import.meta.env.VITE_AUTH0_DOMAIN || '';
39+
process.env.AUTH0_DOMAIN ||
40+
import.meta.env.AUTH0_DOMAIN ||
41+
process.env.VITE_AUTH0_DOMAIN ||
42+
import.meta.env.VITE_AUTH0_DOMAIN ||
43+
'';
3644
const auth0ClientId =
37-
process.env.VITE_AUTH0_CLIENT_ID || import.meta.env.VITE_AUTH0_CLIENT_ID || '';
45+
process.env.AUTH0_CLIENT_ID ||
46+
import.meta.env.AUTH0_CLIENT_ID ||
47+
process.env.VITE_AUTH0_CLIENT_ID ||
48+
import.meta.env.VITE_AUTH0_CLIENT_ID ||
49+
'';
3850
const session = authBypass
3951
? { user: { name: 'Dev User', email: 'dev@localhost' }, accessToken: 'dev-dummy-token' }
4052
: await getSession(Astro.request);
@@ -179,15 +191,18 @@ const sponsors = [
179191
} catch (e) {
180192
console.error('Local sign-out failed:', e);
181193
}
182-
// 2) Clear the Auth0 session and federate logout to the upstream
183-
// IdP (CILogon), so the next sign-in shows the login screen
184-
// instead of silently re-authenticating.
194+
// 2) Clear the Auth0 session so the next sign-in shows the login
195+
// screen instead of silently re-authenticating. We don't pass
196+
// ?federated: CILogon exposes no OIDC end_session_endpoint, so
197+
// Auth0 can't end its session (it would just log
198+
// federated_logout_failed). The CILogon/institution SSO
199+
// session can't be cleared programmatically.
185200
const params = new URLSearchParams({
186201
client_id: auth0ClientId,
187202
returnTo: window.location.origin,
188203
});
189204
window.location.href =
190-
`https://${auth0Domain}/v2/logout?federated&${params.toString()}`;
205+
`https://${auth0Domain}/v2/logout?${params.toString()}`;
191206
});
192207
</script>
193208

0 commit comments

Comments
 (0)