8000 Enforce the post-logout redirect URI client policy on logout requests by Praiztl · Pull Request #55704 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Enforce the post-logout redirect URI client policy on logout requests - #55704

Open
Praiztl wants to merge 1 commit into
keycloak:mainfrom
Praiztl:fix/52578-enforce-post-logout-redirect
Open

Praiztl wants to merge 1 commit into
keycloak:mainfrom
Praiztl:fix/52578-enforce-post-logout-redirect

Conversation

@Praiztl
@Praiztl Praiztl commented Dec 1, 2026
Copy link
Copy Markdown

Closes #52578

Decisions and assumptions:

  • Uses a dedicated POST_LOGOUT_REDIRECT_URI client-policy event rather than reusing LOGOUT_REQUEST, which fires in the unauthenticated browser-logout path and would drag client-auth and holder-of-key executors into it; this mirrors the existing AUTHORIZATION_REQUEST_REDIRECT_URI event.
  • The event fires only after the URI has matched the client's registered post-logout list, so the policy sees the same validated value as for authorization redirects.
  • The integration test covers the enforcement path; the compliant path reuses the shared verifyRedirectUri logic already covered by the executor tests.

This pull request was prepared with the help of an AI agent.

@Praiztl
Praiztl marked this pull request as ready for review December 1, 2026 16:42
@Praiztl
Praiztl requested a review from a team as a code owner December 1, 2026 16:42
Copilot AI balanced review requested due to automatic review settings December 1, 2026 16:42
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Logout policy checks the raw rather than resolved redirect URI, risking bypasses or false rejections, while the new test uses an internal UUID and can pass without exercising enforcement.

2 open issues
What changed in this PR

This PR addresses #52578 by extending Keycloak’s secure redirect URI policy enforcement to RP-initiated logout requests, beyond client configuration updates.

Changes:

  • Adds a dedicated post-logout redirect URI policy event and context.
  • Invokes policy enforcement after registered-URI validation and rejects policy violations.
  • Adds an integration test intended to cover rejection of an insecure post-logout redirect.
File Description
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​client/​policies/​SecureRedirectUrisEnforcerPostLogoutTest.java Adds logout policy regression coverage.
services/​src/​main/​java/​org/​keycloak/​services/​clientpolicy/​executor/​SecureRedirectUrisEnforcerExecutor.java Handles logout redirects using shared URI policy validation.
services/​src/​main/​java/​org/​keycloak/​services/​clientpolicy/​context/​PostLogoutRedirectUriContext.java Carries the client and redirect URI for policy evaluation.
services/​src/​main/​java/​org/​keycloak/​protocol/​oidc/​endpoints/​LogoutEndpoint.java Triggers redirect policy checks and handles rejection.
server-spi/​src/​main/​java/​org/​keycloak/​services/​clientpolicy/​ClientPolicyEvent.java Defines the dedicated logout redirect event.

Review effort: Balanced

@Praiztl
Praiztl force-pushed the fix/52578-enforce-post-logout-redirect branch from e53289f to 2613f80 Compare December 1, 2026 17:03
Copilot AI balanced review requested due to automatic review settings December 1, 2026 17:03
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new validation event can cause matching reject-request policies to block browser logout even with a compliant URI and no redirect enforcer, because RejectRequestExecutor does not ignore POST_LOGOUT_REDIRECT_URI.

1 open issue
2 resolved since last review

Review effort: Balanced

// The URI is a registered post-logout redirect URI; also enforce any client policy on it,
// so logout requests are subject to the same restrictions as CRUD and authorization redirects.
try {
session.clientPolicy().triggerOnEvent(new PostLogoutRedirectUriContext(client, validatedRedirectUri));
@Praiztl
Praiztl force-pushed the fix/52578-enforce-post-logout-redirect branch from 2613f80 to db26d27 Compare December 1, 2026 19:30
Copilot AI balanced review requested due to automatic review settings December 1, 2026 19:30
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Post-logout URI validation ignores the open-redirect override and incorrectly requires explicit ports for registered HTTPS loopback URIs, rejecting valid configurations.

3 open issues

Review effort: Balanced

@Praiztl
Praiztl force-pushed the fix/52578-enforce-post-logout-redirect branch from db26d27 to af350c3 Compare December 2, 2026 09:26
Copilot AI balanced review requested due to automatic review settings December 2, 2026 09:26
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Logout validation incorrectly rejects an otherwise valid IPv4 loopback redirect with an explicit port because it applies registration rules instead of request-parameter rules.

2 open issues
2 resolved since last review

Review effort: Balanced

@Praiztl
Praiztl force-pushed the fix/52578-enforce-post-logout-redirect branch from af350c3 to 72834d4 Compare December 2, 2026 11:30
Copilot AI balanced review requested due to automatic review settings December 2, 2026 11:30
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the post-logout redirect policy change.

1 open issue
1 resolved since last review

Review effort: Balanced

@Praiztl
Praiztl force-pushed the fix/52578-enforce-post-logout-redirect branch from 72834d4 to 7f5653d Compare December 3, 2026 11:18
Copilot AI balanced review requested due to automatic review settings December 3, 2026 11:18
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Comments incorrectly imply that browser logout later emits LOGOUT_REQUEST; clarify that unrelated executors should ignore the redirect-validation event without suggesting their checks run afterward.

2 open issues

Review effort: Balanced

Comment on lines +81 to +82
* logout response can redirect to it. Executors unrelated to redirect URI validation should
* ignore it and perform their checks during the regular logout event.
Adds a dedicated POST_LOGOUT_REDIRECT_URI client-policy event (mirroring AUTHORIZATION_REQUEST_REDIRECT_URI), fired from LogoutEndpoint after the URI matches the client's registered post-logout list, so SecureRedirectUrisEnforcerExecutor applies the same policy to logout requests as to CRUD and authorization redirects. Reusing LOGOUT_REQUEST was rejected because it fires in the browser logout path and would pull client-auth and holder-of-key executors into it. Refs keycloak#52578.

Signed-off-by: Tochukwu Chikezie <95018735+Praiztl@users.noreply.github.com>
@Praiztl
Praiztl force-pushed the fix/52578-enforce-post-logout-redirect branch from 7f5653d to b537d13 Compare December 4, 2026 10:00
Copilot AI balanced review requested due to automatic review settings December 4, 2026 10:00
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the changes extending secure redirect URI policy enforcement to post-logout redirects.

2 open issues

Review effort: Balanced

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.

SecureRedirectUrisEnforcerExecutor enforces PostLogoutRedirectURIs only on CRUD operations

2 participants

0