Repository navigation
Keep the /auth mount path when ProxyFix applies X-Forwarded-Prefix - #74603
Merged
Merged
Conversation
The FAB Flask app is mounted under /auth of the API server, so its WSGI requests arrive with SCRIPT_NAME set to '<base_url path>/auth'. ProxyFix assigns X-Forwarded-Prefix to SCRIPT_NAME outright, which drops the /auth segment, and every url_for result on the Security pages (the Add/Edit/Show links for roles and users) then points at the React shell instead of the FAB view (apache#70389). Wrap ProxyFix so that only the /auth mount segment is taken out of SCRIPT_NAME beforehand and appended again afterwards. The forwarded prefix replaces the base_url path, so stashing the whole SCRIPT_NAME (as apache#70797 did) doubles the subpath when base_url has a path; stashing just the mount segment gives '<forwarded prefix>/auth' in both setups. The mount segment is derived from the constants the API server uses to mount the auth manager app.
vincbeck
approved these changes
Oct 13, 2026
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
28 of 93 tasks
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.
When Airflow runs behind a reverse proxy on a URL subpath with
[fab] enable_proxy_fix = True, the Add / Edit / Show links on the FAB Security pages (/auth/roles/list/,/auth/users/list/) come out without the/authsegment, land on the React shell and bounce back to the dashboard. That is #70389.Cause: the FAB Flask app is mounted under
/authof the API server, so WSGI requests arrive withSCRIPT_NAME = "<base_url path>/auth". Werkzeug'sProxyFixassignsX-Forwarded-PrefixtoSCRIPT_NAMEoutright, so the/authsegment is gone and everyurl_forresult drops it.Fix: wrap
ProxyFixin two small WSGI middlewares. The outer one takes only the/authmount segment out ofSCRIPT_NAMEbeforeProxyFixruns, the inner one appends it to whatever prefixProxyFixleft. The forwarded prefix stands in for thebase_urlpath, so this gives<forwarded prefix>/authwhetherbase_urlhas a path or not.The earlier attempt (#70797) stashed the whole
SCRIPT_NAME, which doubled the subpath whenbase_urlhas a path; that is the case that got it closed. Withbase_url = https://example.com/myns/myreleaseandX-Forwarded-Prefix: /myns/myrelease:/myns/myrelease/roles/add/myns/myrelease/myns/myrelease/auth/roles/add/myns/myrelease/auth/roles/addThe mount segment is derived from
AUTH_MANAGER_FASTAPI_APP_PREFIXandAPI_ROOT_PATH, the same constants the API server uses to mount the auth manager app, rather than hardcoded.Tests: new
providers/fab/tests/unit/fab/www/extensions/test_init_wsgi_middlewares.pycovers the mounted and unmounted app with and without a forwarded prefix,base_urlwith and without a path, a forwarded prefix equal to the mount path, a trailing slash on the prefix, and proxy fix disabled. The file is also removed from the overlooked-tests allow-list.closes: #70389
related: #70797
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.