Skip to content

Commit 8bc1471

Browse files
authored
Fix Flask Login user setting for Flask 2.2 and Flask-Login 0.6.2 (#25318)
The Google openid auth backend of ours had hard-coded way of seting the current user which was not compatible with Flask 2.2 With Flask-login 0.6.2 the user is stored in g module of flask, where before, it was stored in _request_ctx_stack. Unforatunately the google_openid rather than using _update_request_context_with_user set the user directly in context. In Flask-login 0.6.2 this stopped working. This change switches to use the _update_request_context_with_user method rather than directly storing user in context which works before and after the Flask-Login 0.6.2 change.
1 parent 7e631a9 commit 8bc1471

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

β€Žairflow/providers/google/common/auth_backend/google_openid.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import google
2424
import google.auth.transport.requests
2525
import google.oauth2.id_token
26-
from flask import Response, _request_ctx_stack, current_app, request as flask_request # type: ignore
26+
from flask import Response, current_app, request as flask_request # type: ignore
2727
from google.auth import exceptions
2828
from google.auth.transport.requests import AuthorizedSession
2929
from google.oauth2 import service_account
@@ -101,8 +101,7 @@ def _lookup_user(user_email: str):
101101

102102

103103
def _set_current_user(user):
104-
ctx = _request_ctx_stack.top
105-
ctx.user = user
104+
current_app.appbuilder.sm.lm._update_request_context_with_user(user=user) # type: ignore[attr-defined]
106105

107106

108107
T = TypeVar("T", bound=Callable)

0 commit comments

Comments
 (0)