fix(signout): chain oauth2-proxy and Cognito logout after Django sign-out#30
Closed
awais786 wants to merge 1 commit into
Closed
fix(signout): chain oauth2-proxy and Cognito logout after Django sign-out#30awais786 wants to merge 1 commit into
awais786 wants to merge 1 commit into
Conversation
…-out UserStore.signOut() previously cleared only Layer 1 (Django session via POST /auth/sign-out/) before redirecting to the portal. The two remaining auth layers — the _oauth2_proxy cookie + Redis session, and the Cognito SSO session — were left intact. The next visit to any app in the bundle silently re-authenticated as the same user, no Cognito prompt either, because the upstream SSO session was still alive. VITE_OIDC_LOGOUT_URL and VITE_OIDC_CLIENT_ID were already configured in .env, and buildOAuth2SignOutUrl() was already exported from lib/oauth2-proxy.ts — the wiring was sat there unused. After this commit, the redirect chain is: POST /auth/sign-out/ ← Layer 1 (Django) → /oauth2/sign_out?rd=<cognito-logout> ← Layer 2 (oauth2-proxy cookie + Redis) → <cognito>/logout?...&logout_uri=... ← Layer 3 (Cognito SSO session) → portal URL ← lands outside ForwardAuth When OIDC env vars are not set, falls back to oauth2-proxy-only (best effort) so non-mPass deployments still see Layer 2 cleared. Cognito's allowed sign-out URLs must include the portal URL — see CLAUDE.md "Cognito requirement". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
Author
|
Closing — the middleware mismatch detection in #29 covers the session-sharing repro. The in-app signOut 3-layer chain (Django → oauth2-proxy → Cognito) is correct behavior but not load-bearing given #29 self-corrects on any path that produces an upstream-identity change. Can revisit if/when we explicitly want synchronous (vs lazy) logout. |
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.
Summary
UserStore.signOut()was clearing only Layer 1 (Django session viaPOST /auth/sign-out/) and then redirecting to the portal. The two upstream layers were left intact:_oauth2_proxycookie + Redis sessionVITE_OIDC_LOGOUT_URLandVITE_OIDC_CLIENT_IDwere already configured inapps/web/.env.buildOAuth2SignOutUrl()was already exported fromapps/web/core/lib/oauth2-proxy.ts. The wiring was sat there unused.New flow
When
VITE_OIDC_LOGOUT_URL/VITE_OIDC_CLIENT_IDare not set, falls back to/oauth2/sign_outonly — best effort for non-mPass deployments.Cognito config requirement
Per
CLAUDE.md"Cognito requirement": the portal URL must be registered as an Allowed sign-out URL in the Cognito app client.http://localhosthttps://<plane-host's parent domain>If this is missing, Cognito will reject the
logout_uriand the user will see a Cognito error page. This is a config concern, not a code one.Repro / verification
Before:
After:
/oauth2/sign_out→ Cognito/logout→ portal.Test plan
VITE_OIDC_LOGOUT_URLin.env, rebuild web — sign-out still clears oauth2-proxy (visible in Network tab); Cognito session unaffected (documented best-effort fallback).Complementary
This is the client-side counterpart to #29 (server-side mismatch detection). Both fix the "stale session" class of bug from different angles:
Out of scope
Outline / Penpot / Twenty have their own in-app sign-out buttons with the same single-layer-only bug. Separate PRs forthcoming if needed — the per-app mismatch detection PRs (#19, #18, #8 respectively) already cover the recovery path in the meantime.
🤖 Generated with Claude Code