feat: add FAB AuthManager override to safely skip session rotation fo… #59611
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.
Problem:
Currently, calling auth_user_oauth() outside a Flask request context triggers RuntimeError: Working outside request context. The only workaround is overriding the private _rotate_session_id method, which is not recommended.
Solution:
Add a rotate_session_id=False option to skip session rotation safely.
Implement TheOverrideFabAuthManager.create_token() that wraps the token creation in an application and request context.
This approach avoids touching private methods while enabling token generation for API clients or background processes.
Testing:
Verified token generation works without a request context.
Tested compatibility with Airflow API v2 calls.
Existing FAB authentication tests pass.
Notes:
No backwards-incompatible changes.
No new dependencies.
Closes / Related Issues:
Closes: #59600