Repository navigation
BACKPORT: Apply browser security headers on SP-initiated SAML endpoints (#54159) - #55043
Merged
Merged
Conversation
…ak#54159) * Apply browser security headers on SP-initiated SAML endpoints Return Response synchronously from /protocol/saml GET/POST (including artifact resolution) so KeycloakSecurityHeadersFilter can apply realm browser security headers. Previously @suspended AsyncResponse closed the session before the filter ran, omitting CSP and X-Frame-Options. Closes keycloak#54122 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * Keep SAML artifact resolution on saml-artifact-pool Restore async artifact SOAP I/O so a slow SP does not block shared HTTP workers, while still applying realm browser security headers before AsyncResponse resume for SP-initiated SAML endpoints. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * Preserve front-channel logout CSP when applying SAML security headers Route async SAML header application through SecurityHeadersProvider so allowFrameSrc from FrontChannelLogoutHandler is not overwritten by raw realm defaults. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * Apply SAML security headers after AsyncResponseTransaction selects the final response Rollback-generated artifact error pages were missing realm browser security headers because they replaced an already-decorated success response. Apply headers on commit/rollback after the final response is chosen, and cover the artifact resolution rollback path in SamlSecurityHeadersTest. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * Rebuild SAML responses when applying browser security headers Mutating Response.getHeaders() is not propagated by Quarkus REST on AsyncResponse resume. Rebuild the Response via Response.fromResponse so realm security headers are present on the wire. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> --------- Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> (cherry picked from commit 42a3b96)
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail. 9A48 com>
mposolda
approved these changes
Nov 12, 2026
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.
Return Response synchronously from /protocol/saml GET/POST (including
artifact resolution) so KeycloakSecurityHeadersFilter can apply realm
browser security headers. Previously @suspended AsyncResponse closed the
session before the filter ran, omitting CSP and X-Frame-Options.
Closes #54122
(cherry picked from commit 42a3b96)