You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Apply browser security headers on SP-initiated SAML endpoints - #54159
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.
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.
Closeskeycloak#54122
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
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>
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>
Add GET and POST regression tests that omit all SAML parameters and assert status 400 plus the realm's configured security headers on the HTML error page. Both new tests send valid AuthnRequests, leaving this separately decorated early-error path untested even though error pages are explicitly part of #54122.
@edewit Hi Erik, the artifact worker pool and logout CSP handling look good now. There’s still one gap: if the artifact transaction fails to commit, AsyncResponseTransaction.rollback() replaces the response with a fresh 500 error page, losing the security headers applied here.
Could we apply the headers after the final response is selected and add a regression test for that rollback path? The current tests only send SAMLRequest, so they don’t cover artifact resolution.
…e 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>
AsyncResponseTransaction now applies browser security headers to the response that is actually resumed after commit/rollback selects it, so a rollback-generated 500 still gets the realm headers. Added testBrowserSecurityHeadersOnArtifactResolutionRollback covering the artifact path through that transaction.
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>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Generated security headers append to existing CSP values, causing browsers to enforce intersecting policies that may block resources or frames permitted by the realm policy.
…onses
Resolve SamlClient conflict by keeping both unsigned-response helpers from
main and artifact-request helpers from this branch. Clear copied header
values before applying realm browser security headers so CSP is replaced
rather than duplicated.
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
…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.
Closeskeycloak#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>
#55043)
Closes#54122
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
(cherry picked from commit 42a3b96)
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
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