feat(oidc): implement RP-Initiated Logout - #1829
Open
stevecharon wants to merge 1 commit into
Open
stevecharon wants to merge 1 commit into
stevecharon wants to merge 1 commit into
Conversation
When a user authenticated via OIDC logs out, the frontend only dropped the local session token and redirected to the login view. The session at the identity provider remained active, so clicking the OpenID button logged the user straight back in without presenting any credentials. Perform an RP-Initiated Logout as specified in OpenID Connect RP-Initiated Logout 1.0 when, and only when, the current session was established via OIDC. Sessions of managed and LDAP users are unaffected and keep the previous local-only behavior. The API server does not expose the principal type via /api/v1/user/self, and the OIDC user is intentionally removed from the web storage right after the token exchange. The login view therefore records the ID token in the session storage, which the logout handler consumes as id_token_hint and clears. The UserManager, previously constructed inline in the login view, moves to src/shared/oidc.js so it can be shared. The end session endpoint is taken from the provider's discovery document, so no additional configuration is required. Fixes DependencyTrack/dependency-track#2015 Signed-off-by: stevecharon <37655537+stevecharon@users.noreply.github.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
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.
Perform an RP-Initiated Logout as specified in OpenID Connect RP-Initiated Logout 1.0 when, and only when, the current session was established via OIDC. Sessions of managed and LDAP users are unaffected and keep the previous local-only behavior.
The API server does not expose the principal type via /api/v1/user/self, and the OIDC user is intentionally removed from the web storage right after the token exchange. The login view therefore records the ID token in the session storage, which the logout handler consumes as id_token_hint and clears.
The UserManager, previously constructed inline in the login view, moves to src/shared/oidc.js so it can be shared. The end session endpoint is taken from the provider's discovery document, so no additional configuration is required.
Description
Implements OpenID Connect RP-Initiated Logout.
When a user authenticated via OIDC logs out, the frontend only drops the local
session token and redirects to the login view. The session at the identity
provider stays active, so clicking the OpenID button logs the user straight
back in without presenting any credentials.
Logging out now terminates the session at the identity provider as well, but
only for sessions that were actually established via OIDC. Managed and LDAP
users keep the previous local-only behavior, so this is not a breaking change
and requires no new configuration.
Addressed Issue
Fixes DependencyTrack/dependency-track#2015
Additional Details
Determining at logout time whether the current session came from OIDC is not
straightforward:
/api/v1/user/selfdoes not expose the principal type. Managed users can beidentified by the presence of
suspended, but LDAP users areindistinguishable from OIDC users that way.
oidcUserManager.getUser()returnsnull, becauseLogin.vueremoves theOIDC user right after exchanging the access token for a session token.
Login.vuetherefore records the ID token insessionStorageat the pointwhere the token exchange provably succeeded. The logout handler consumes it as
id_token_hintand clears it. This tracks how the current session wasestablished rather than the account type, which is the more accurate
condition — a user who happens to have an OIDC account but signed in some
other way should not trigger an IdP logout either.
The
UserManagerwas previously constructed inline inLogin.vueand thusunreachable from the header component. It moves to
src/shared/oidc.jsas alazily created singleton that returns
nullwhen OIDC is not configured, socallers can fall back to the local redirect.
Notes:
oidc-client1.11.5 is already in use and shipssignoutRedirect().end_session_endpointcomes from the provider'sdiscovery document;
post_logout_redirect_uridefaults to the frontendorigin including the context path.
Verified against Keycloak using the code flow: after logging out, clicking the
OpenID button again presents the Keycloak login form instead of silently
re-authenticating.
Operators need to register the frontend origin as a post-logout redirect URI
at their IdP. Happy to open a corresponding PR against the docs repo.
Checklist