Skip to content

Make JWTRefreshMiddleware extensible via BaseAuthManager.get_jwt_refresh_middleware() - #70783

Open
stephen-bracken wants to merge 1 commit into
apache:mainfrom
stephen-bracken:make-jwt-extendible
Open

Make JWTRefreshMiddleware extensible via BaseAuthManager.get_jwt_refresh_middleware()#70783
stephen-bracken wants to merge 1 commit into
apache:mainfrom
stephen-bracken:make-jwt-extendible

Conversation

@stephen-bracken

@stephen-bracken stephen-bracken commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

closes: #70720

Make JWTRefreshMiddleware extensible via BaseAuthManager.get_jwt_refresh_middleware()

By moving the JWTRefreshMiddleware initialisation to BaseAuthManager.get_jwt_refresh_middleware(), this allows auth managers to override the JWTRefreshMiddleware behaviour by inheriting from it and using the inherited class in get_fastapi_middlewares instead.

By factoring out the _set_new_token() method from dispatch(), this gives an interface for the inherited token refresh middleware to alter the behaviour of the middleware when setting the tokens.

Also adds the airflow.api_fastapi.app.request_cookie_is_secure() helper to standardise setting HTTP secure cookies

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
  • No

@stephen-bracken stephen-bracken changed the title Make JWTRefreshMiddleware into a standard fastapi middleware Make JWTRefreshMiddleware extensible via BaseAuthManager.get_jwt_refresh_middleware()` Jul 30, 2026
@stephen-bracken stephen-bracken changed the title Make JWTRefreshMiddleware extensible via BaseAuthManager.get_jwt_refresh_middleware()` Make JWTRefreshMiddleware extensible via BaseAuthManager.get_jwt_refresh_middleware() Jul 30, 2026
@stephen-bracken
stephen-bracken force-pushed the make-jwt-extendible branch 3 times, most recently from 474ce7b to 7655032 Compare July 30, 2026 22:56
@stephen-bracken
stephen-bracken marked this pull request as ready for review July 30, 2026 23:38
Comment thread airflow-core/src/airflow/api_fastapi/auth/middlewares/refresh_token.py Outdated
Comment thread airflow-core/src/airflow/api_fastapi/core_api/app.py Outdated
@stephen-bracken
stephen-bracken force-pushed the make-jwt-extendible branch 3 times, most recently from 16198fd to 3a89840 Compare July 31, 2026 19:11
@vincbeck

Copy link
Copy Markdown
Contributor

CI is failing

@stephen-bracken
stephen-bracken force-pushed the make-jwt-extendible branch 6 times, most recently from a8c2ae1 to 3dc4d12 Compare August 1, 2026 16:29
@stephen-bracken

stephen-bracken commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

I've updated _refresh_user to get the current_token from the request object, so now the request object is no longer a redundant argument.

edit: updated _set_new_token to generate the new jwt from the user, so the new_user argument is no longer redundant

@stephen-bracken
stephen-bracken force-pushed the make-jwt-extendible branch 5 times, most recently from 4133591 to 87b198d Compare August 1, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make request cookies available to AuthManager methods

2 participants