fix(proxy): preserve cross-origin redirects - #34
Open
idirze wants to merge 1 commit into
Open
Conversation
ModifyResponse stripped the scheme and host from every 302 Location header, without checking where the redirect pointed. An absolute cross-origin redirect, such as the auth filter sending an unauthenticated browser to the identity provider, was reduced to a bare path that the browser resolved against the proxy, so the OIDC flow never started. Compare the redirect target with the upstream origin and rewrite only when they match. Relative Location headers are left alone, as are redirects to any other origin. Refs OKDP#33
abir-oumghar
approved these changes
Sep 1, 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.
Description
ModifyResponsestripped the scheme and host from every302 Locationheader without checking where the redirect pointed.As a result, any absolute cross-origin redirect could be reduced to a relative path and incorrectly resolved by the browser against
spark-web-proxy.For example, when the Spark authentication filter redirects an unauthenticated browser to an OIDC identity provider:
the proxy rewrote the
Locationto:The browser then resolved that relative path against
spark-web-proxy:resulting in a
404instead of continuing the OIDC authentication flow.This change:
Locationheaders unchanged;This preserves the existing Spark redirect behavior while allowing redirects to external origins, including identity providers, to pass through correctly.
Related Issue
Refs #33
Type of Change
How to Test
Run the project test suite:
make testThe issue can be reproduced using the Spark authentication filter with PKCE disabled, causing it to emit an HTTP
302redirect to Keycloak:Then access the Spark History UI through
spark-web-proxy.Before
The external OIDC redirect is rewritten and resolved against the proxy:
and returns
404.After
The original cross-origin
Locationis preserved:and the browser is correctly redirected to the identity provider.
Internal Spark redirects continue to be rewritten through the proxy, while relative redirects remain unchanged.
Checklist