Skip to content

Full-chain logout via OIDC RP-initiated logout - #62

Merged
einari merged 3 commits into
mainfrom
feature/full-chain-logout
Jul 23, 2026
Merged

Full-chain logout via OIDC RP-initiated logout#62
einari merged 3 commits into
mainfrom
feature/full-chain-logout

Conversation

@einari

@einari einari commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Logging out only cleared the local AuthProxy session, leaving the user signed in at the identity provider so the next visit silently re-authenticated. /.cratis/logout now performs a full-chain logout that also ends the session at the provider.

Added

  • /.cratis/logout now performs OIDC RP-initiated logout: for a session established through an OIDC provider it redirects the browser to the provider's end_session_endpoint with id_token_hint and a post_logout_redirect_uri pointing at the new /.cratis/logout/callback, which then clears every AuthProxy cookie and redirects to the validated final target.
  • Cratis:AuthProxy:... OIDC applications should register https://<proxy-host>/.cratis/logout/callback as a permitted post-logout redirect URI.

Changed

  • The final redirect target is now validated against the post-logout allow-list on both legs of the round-trip (initiation and callback), and is carried across the identity-provider round-trip in a short-lived HTTP-only cookie rather than in the URL.
  • OAuth 2.0 providers (such as GitHub) have no standard OIDC end-session endpoint and cannot be force-logged-out via a redirect; those sessions — and any request with no active OIDC session — fall back to the previous local-only logout (clear cookies + redirect). See Documentation/configuration/logout.md.

einari and others added 3 commits July 23, 2026 19:45
Add the plumbing required for RP-initiated logout: persist which provider
scheme established a session into the authentication cookie, and add an
IEndSessionEndpointResolver that discovers an OIDC provider's end-session
endpoint from its OpenID configuration. OAuth 2.0 providers, unknown schemes,
and discovery failures resolve to null so callers can fall back to a
local-only logout.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Previously /.cratis/logout only cleared the local session, leaving the user
signed in at the identity provider so the next visit silently re-authenticated.

For an OIDC session the middleware now redirects the browser to the provider's
end-session endpoint with id_token_hint and a post_logout_redirect_uri pointing
at a new /.cratis/logout/callback, carrying the validated final target across
the round-trip in a short-lived HTTP-only cookie; the callback then clears every
AuthProxy cookie and redirects to the final target. OAuth 2.0 providers (e.g.
GitHub) have no end-session endpoint, so they fall back to the previous
local-only logout. The redirect allow-list is validated on both legs and
extracted into PostLogoutRedirectPolicy so neither leg can be an open redirect.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Cover the RP-initiated redirect to the end-session endpoint with id_token_hint
and post_logout_redirect_uri, the OAuth/no-end-session and no-active-session
fallbacks, the post-logout callback clearing cookies and redirecting to the
carried target, its open-redirect defense, and the end-session endpoint resolver
across OIDC, OAuth, and missing-scheme cases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@einari einari added the minor label Jul 23, 2026
@einari
einari merged commit fc65fe3 into main Jul 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant