Repository navigation
Make JWTRefreshMiddleware extensible via BaseAuthManager.get_jwt_refresh_middleware() - #70783
Conversation
0fb0bdd to
9502fe9
Compare
JWTRefreshMiddleware extensible via BaseAuthManager.get_jwt_refresh_middleware()`
JWTRefreshMiddleware extensible via BaseAuthManager.get_jwt_refresh_middleware()`JWTRefreshMiddleware extensible via BaseAuthManager.get_jwt_refresh_middleware()
474ce7b to
7655032
Compare
16198fd to
3a89840
Compare
|
CI is failing |
a8c2ae1 to
3dc4d12
Compare
d0d9932 to
3702205
Compare
I have added |
25b289d to
8dbd6d9
Compare
8dbd6d9 to
aac7cf4
Compare
JWTRefreshMiddleware extensible via BaseAuthManager._get_jwt_refresh_middleware()JWTRefreshMiddleware extensible via BaseAuthManager.get_jwt_refresh_middleware()
aac7cf4 to
4037eb9
Compare
4037eb9 to
2fde32e
Compare
|
I am trying to understand, why it is breaking? Do we really need |
|
@vincbeck The original implementation of this middleware made an implicit assumption that the Airflow JWT can fully reconstruct the user model for the request. The That assumption is broken for auth managers that use additional cookies, e.g. in #70800 I added Adding the |
|
The |
|
But do we really need this |
|
I see your point - I can modify the init procedure to prepend the jwt middleware if present. |
vincbeck
left a comment
There was a problem hiding this comment.
LGTM but I would like to have @pierrejeambrun's review
pierrejeambrun
left a comment
There was a problem hiding this comment.
Thanks for iterating on this, I think the current shape is much better: keeping the JWT middleware in its own overridable method keeps old providers working on the new core, and preserves the middleware order. A few things to fix before it's ready, the first one is breaking the API server (and the standalone CI job). Could you also update the PR description? It still mentions use_jwt_middleware and _set_new_token.
|
I've fixed the CI issues and added a |
closes: #70720
Make JWTRefreshMiddleware extensible via BaseAuthManager.get_jwt_refresh_middleware()
Refactor the initialisation flow for the
JWTRefreshMiddlewareto give greater control to auth managers over how this middleware gets initialised.By moving the
JWTRefreshMiddlewareinitialisation toBaseAuthManager.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._refresh_user()and_build_cookie_headers()methods to publicrefresh_user()andbuild_cookie_headers()methods to allow accessing any cookies or state information from the request and setting cookies in the response.get_extra_cookies()allows subclasses to add / clear additional cookies in the response when a new user token is issued.generate_new_user_token()allows subclasses to control how JWTs are issued for new users.Also adds the
airflow.api_fastapi.app.request_cookie_is_secure()helper to standardise setting HTTP secure cookiesWas generative AI tooling used to co-author this PR?