Skip to content

Keep the /auth mount path when ProxyFix applies X-Forwarded-Prefix - #74603

Merged
vincbeck merged 1 commit into
apache:mainfrom
bnspopi:fix/fab-proxy-fix-auth-mount-70389
Oct 13, 2026
Merged

vincbeck merged 1 commit into
apache:mainfrom
bnspopi:fix/fab-proxy-fix-auth-mount-70389

Conversation

@bnspopi

@bnspopi bnspopi commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

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 /auth segment, land on the React shell and bounce back to the dashboard. That is #70389.

Cause: the FAB Flask app is mounted under /auth of the API server, so WSGI requests arrive with SCRIPT_NAME = "<base_url path>/auth". Werkzeug's ProxyFix assigns X-Forwarded-Prefix to SCRIPT_NAME outright, so the /auth segment is gone and every url_for result drops it.

Fix: wrap ProxyFix in two small WSGI middlewares. The outer one takes only the /auth mount segment out of SCRIPT_NAME before ProxyFix runs, the inner one appends it to whatever prefix ProxyFix left. The forwarded prefix stands in for the base_url path, so this gives <forwarded prefix>/auth whether base_url has a path or not.

The earlier attempt (#70797) stashed the whole SCRIPT_NAME, which doubled the subpath when base_url has a path; that is the case that got it closed. With base_url = https://example.com/myns/myrelease and X-Forwarded-Prefix: /myns/myrelease:

Add link
main /myns/myrelease/roles/add
#70797 /myns/myrelease/myns/myrelease/auth/roles/add
this PR /myns/myrelease/auth/roles/add

The mount segment is derived from AUTH_MANAGER_FASTAPI_APP_PREFIX and API_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.py covers the mounted and unmounted app with and without a forwarded prefix, base_url with 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?
  • Yes (Claude Code)

Generated-by: Claude Code following the guidelines


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {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.

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
vincbeck merged commit 2816cb0 into apache:main Oct 13, 2026
81 checks passed
@boring-cyborg

boring-cyborg Bot commented Oct 13, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FAB Security views (Add/Edit/Show role/user links) miss /auth prefix when running behind a subpath reverse proxy (enable_proxy_fix + X-Forwarded-Prefix)

2 participants