Fix FAB Security page links losing the /auth prefix behind a subpath proxy - #70797
Open
Dhruv-kys wants to merge 1 commit into
Open
Fix FAB Security page links losing the /auth prefix behind a subpath proxy#70797Dhruv-kys wants to merge 1 commit into
Dhruv-kys wants to merge 1 commit into
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
…proxy Deployments serving Airflow under a URL subpath could not add, edit or view Roles and Users: the links silently resolved to the React SPA, which bounced the user back to the Dashboard with no error.
Dhruv-kys
force-pushed
the
fix/70389-fab-proxy-fix-mount-prefix
branch
from
August 10, 2026 19:32
a27dca3 to
e75d66f
Compare
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.
FAB's Security pages generated Add/Edit/Show links without the
/authblueprintprefix when Airflow runs behind a reverse proxy on a URL subpath.
closes: #70389
Problem
With
[fab] enable_proxy_fix = Trueand the proxy sendingX-Forwarded-Prefix,links on
/auth/roles/list/and/auth/users/list/point at/<subpath>/roles/addinstead of/<subpath>/auth/roles/add. The broken linkresolves to the React SPA shell, which has no client-side route for
roles/usersand redirects to the Dashboard — so the buttons appear to donothing, with no visible error.
Cause
The Flask app is mounted at
/inside a FastAPI sub-app(
fab_auth_manager.py:256), which is itself mounted at/auth(
api_fastapi/app.py:206), so Starlette passesSCRIPT_NAME=/authinto the WSGIenviron. Werkzeug's
ProxyFixthen assignsX-Forwarded-PrefixtoSCRIPT_NAMErather than prepending to it:That discards the mount path. Since
url_forbuilds every URL asSCRIPT_NAME + rule, all FAB-generated links lose/auth. The list pagesthemselves keep the prefix because those URLs come from the React shell's
configuration rather than from
url_for, which is why the bug looks selective.Fix
Wrap
ProxyFixin a pair of small WSGI middlewares: the outer one stashes themount path and clears
SCRIPT_NAMEsoProxyFixsees an empty slot, and theinner one appends the mount path back once the forwarded prefix has been
applied. The result is always
forwarded_prefix + mount_path.An earlier approach re-appended the mount path only when
SCRIPT_NAMEdifferedfrom its original value. That is wrong when the proxy subpath happens to equal
the mount path (
X-Forwarded-Prefix: /auth): the two values match, the guardskips, and the prefix is silently dropped. The stash/restore pair needs no such
comparison; that case is covered by the
subpath-proxy-prefix-matching-mount-pathtest.Testing
New
providers/fab/tests/unit/fab/www/extensions/test_init_wsgi_middlewares.pycovers mounted/unmounted x forwarded-prefix/no-prefix, the equal-prefix edge
case, and proxy-fix disabled. Two cases fail without the fix
(
mounted-behind-subpath-proxyandsubpath-proxy-prefix-matching-mount-path);the other four pass either way and act as controls against a fix that
over-applies the prefix.
This also removes the module from the
OVERLOOKED_TESTSallow-list inairflow-core/tests/unit/always/test_project_structure.py, which the project isdriving to zero.
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5) following the guidelines