Skip to content

Commit 8cbf934

Browse files
aa3pankajjedcunningham
authored andcommitted
Adding missing login provider related methods from Flask-Appbuilder (#21294)
(cherry picked from commit 38894e8)
1 parent 7e80127 commit 8cbf934

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

airflow/www/fab_security/manager.py

+15
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def __init__(self, appbuilder):
187187
# Role Mapping
188188
app.config.setdefault("AUTH_ROLES_MAPPING", {})
189189
app.config.setdefault("AUTH_ROLES_SYNC_AT_LOGIN", False)
190+
app.config.setdefault("AUTH_API_LOGIN_ALLOW_MULTIPLE_PROVIDERS", False)
190191

191192
# LDAP Config
192193
if self.auth_type == AUTH_LDAP:
@@ -292,11 +293,21 @@ def get_roles_from_keys(self, role_keys: List[str]) -> Set[role_model]:
292293
log.warning(f"Can't find role specified in AUTH_ROLES_MAPPING: {fab_role_name}")
293294
return _roles
294295

296+
@property
297+
def auth_type_provider_name(self):
298+
provider_to_auth_type = {AUTH_DB: "db", AUTH_LDAP: "ldap"}
299+
return provider_to_auth_type.get(self.auth_type)
300+
295301
@property
296302
def get_url_for_registeruser(self):
297303
"""Gets the URL for Register User"""
298304
return url_for(f"{self.registeruser_view.endpoint}.{self.registeruser_view.default_view}")
299305

306+
@property
307+
def get_user_datamodel(self):
308+
"""Gets the User data model"""
309+
return self.user_view.datamodel
310+
300311
@property
301312
def get_register_user_datamodel(self):
302313
"""Gets the Register User data model"""
@@ -307,6 +318,10 @@ def builtin_roles(self):
307318
"""Get the builtin roles"""
308319
return self._builtin_roles
309320

321+
@property
322+
def api_login_allow_multiple_providers(self):
323+
return self.appbuilder.get_app.config["AUTH_API_LOGIN_ALLOW_MULTIPLE_PROVIDERS"]
324+
310325
@property
311326
def auth_type(self):
312327
"""Get the auth type"""

setup.cfg

+6-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ install_requires =
104104
# https://github.com/readthedocs/sphinx_rtd_theme/issues/1115
105105
docutils<0.17
106106
flask>=1.1.0, <2.0
107-
flask-appbuilder>=3.3.4, <4.0.0
107+
# We are tightly coupled with FAB version because we vendored in part of FAB code related to security manager
108+
# This is done as part of preparation to removing FAB as dependency, but we are not ready for it yet
109+
# Every time we update FAB version here, please make sure that you review the classes and models in
110+
# `airflow/www/fab_security` with their upstream counterparts. In particular, make sure any breaking changes,
111+
# for example any new methods, are accounted for.
112+
flask-appbuilder==3.4.4
108113
flask-caching>=1.5.0, <2.0.0
109114
flask-login>=0.3, <0.5
110115
# Strict upper-bound on the latest release of flask-session,

0 commit comments

Comments
 (0)