Fix FabAuthManager.get_url_login() dropping next_url, losing deep-link redirects after login - #73134
Merged
vincbeck merged 1 commit intoSep 14, 2026
Conversation
FabAuthManager.get_url_login() accepted **kwargs but never read next_url from it, so callers redirecting an unauthenticated or expired-session request to the login page (via providers/fab/src/airflow/providers/fab/www/auth.py, which already passes next_url=request.url) always lost the originally requested URL. After completing login, the user landed on the homepage instead of the deep link they opened, and had to open the same link a second time to reach it. This mirrors the fix already applied to SimpleAuthManager in apache#67965, which was scoped to SimpleAuthManager only and left FabAuthManager with the identical bug. The rest of the redirect chain (flask_appbuilder's AuthOAuthView/ AuthDBView reading `next` from the query string into the OAuth state, and the redirect/get_safe_redirect monkey-patch in providers/fab/www/extensions/init_appbuilder.py that sets the JWT cookie and forwards to that URL) already works correctly, so propagating next_url into the login URL is the only change needed.
|
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
|
vincbeck
approved these changes
Sep 14, 2026
hzitoun-thefork
approved these changes
Sep 14, 2026
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
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.
Fixes #73133 (opened alongside this PR)
What
FabAuthManager.get_url_login()accepted**kwargsbut never used them, so callers passingnext_url=request.url(to redirect the user back to their originally requested page after login) had that value silently discarded. Every unauthenticated/expired-session redirect to/auth/login/therefore lost the deep-link target, and the user landed on the homepage after logging in.This is the same class of bug fixed for
SimpleAuthManagerin #67476 / #67483 / #67965, but that fix was explicitly scoped toSimpleAuthManageronly.FabAuthManager(used for any FAB-backed auth: DB, LDAP, OAuth/SSO, etc.) had the identical bug and was left unpatched.Why only one change is needed here (unlike the Simple auth manager fix)
SimpleAuthManagerneeded two PRs: one to propagatenext_urlinto the login URL (#67965) and one to make the login route actually consumenexton completion (#67483), because its login route is a bespoke FastAPI implementation with no built-in notion of "return to this page."FabAuthManagerdoesn't need the second half: it delegates toflask_appbuilder's ownAuthOAuthView/AuthDBView, whoselogin()view already readsnextfrom the query string and encodes it into the OAuthstate(or session, for non-OAuth backends), and whoseredirect/get_safe_redirectare already monkey-patched byproviders/fab/src/airflow/providers/fab/www/extensions/init_appbuilder.pyto Airflow's own versions (providers/fab/src/airflow/providers/fab/www/views.py), which set the_tokenJWT cookie and forward to that URL. I traced this end-to-end and confirmed it already works correctly — the only missing link wasnext_urlnever making it into the initial/auth/login/URL in the first place.So this PR only needs to touch
get_url_login(), mirroring the exact propagation fix from #67965:Tests
Added
test_get_url_login_with_next_urlandtest_get_url_login_without_next_url_kwargtoTestFabAuthManager, mirroring the tests added forSimpleAuthManagerin #67965.Verified manually against the released
apache-airflow-providers-fab==3.2.0package (not just againstmain) by patching the installedget_url_loginand exercising it directly:next_urlkwarg → unchanged bare login URL (backward compatible)next_urlprovided → correctly appended as a url-encodednextquery paramnext_url=None→ falls back to the bare URLnext_urlcontaining spaces/&/?→ properly percent-encoded, not passed through rawHow I found this
Root-caused while investigating a real-world report from our Airflow 3 deployment (
FabAuthManager+ OAuth SSO): a data engineer reported that a deep link opened after session expiry always landed on the homepage, requiring a second click on the same link to actually reach the target. Filed as issue #73133 with full reproduction details and the trace of the surrounding call chain.Checklist
next_urlis not supplied,get_url_login()returns exactly the same value as before