Repository navigation
Conversation
There was a problem hiding this comment.
🟡 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
e53289f to
2613f80
Compare
There was a problem hiding this comment.
🟡 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)); |
2613f80 to
db26d27
Compare
db26d27 to
af350c3
Compare
There was a problem hiding this comment.
🟡 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
af350c3 to
72834d4
Compare
72834d4 to
7f5653d
Compare
There was a problem hiding this comment.
🟡 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
| * 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>
7f5653d to
b537d13
Compare


Closes #52578
Decisions and assumptions:
This pull request was prepared with the help of an AI agent.