Implement FabAuthManager.refresh_user for sliding JWT refresh - #70980
Open
roshan-ramees wants to merge 1 commit into
Open
Implement FabAuthManager.refresh_user for sliding JWT refresh#70980roshan-ramees wants to merge 1 commit into
roshan-ramees 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
|
JWTRefreshMiddleware (added in 3.1.4) calls auth_manager.refresh_user on every request; if a user is returned it reissues the _token cookie so long-open UI tabs don't burst 401s at token expiry. BaseAuthManager.refresh_user is a no-op by default. KeycloakAuthManager overrides it; FAB does not, so on FAB deployments the silent-refresh path does nothing and UI tabs 401 every jwt_expiration_time interval. Return the current user unconditionally for authenticated FAB sessions. deserialize_user already re-fetches the user from DB by token['sub'], so the object is fresh and returning it is safe. Related: apache#57065
roshan-ramees
force-pushed
the
fab-refresh-user-sliding-jwt
branch
from
August 3, 2026 10:54
dcf2178 to
e7edc61
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.
What?
Implements
FabAuthManager.refresh_usersoJWTRefreshMiddlewarereissues the_tokencookie on every request when the user is authenticated.Why?
JWTRefreshMiddleware(added in #55506, 3.1.4) drives sliding-refresh of the UI JWT by callingauth_manager.refresh_user(user).BaseAuthManager.refresh_useris a no-op by default.KeycloakAuthManageroverrides it —FabAuthManagerdoes not. On FAB deployments (the default), the silent-refresh path does nothing, so long-open browser tabs burst 401s from concurrent/ui/*and/api/v2/*polls every[api_auth] jwt_expiration_timeinterval.Symptom on our prod (Airflow 3.1.7 + FAB + Google OAuth):
Related open issue: #57065.
How?
Return the current user for authenticated (non-anonymous) FAB sessions.
deserialize_userabove already re-fetches the user from DB bytoken["sub"], so the object is fresh — returning it is safe and adds only one HS512 sign per request (sub-ms).For anonymous / no user, return
Noneto skip the reissue.Tests
Three unit tests covering: authenticated user → returns user; anonymous user → returns None; no user → returns None.
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, following instructions located in the newsfragments README.rst