Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding missing login provider related methods from Flask-Appbuilder #21294

Merged
merged 9 commits into from Feb 17, 2022
15 changes: 15 additions & 0 deletions airflow/www/fab_security/manager.py
Expand Up @@ -216,6 +216,7 @@ def __init__(self, appbuilder):
# Role Mapping
app.config.setdefault("AUTH_ROLES_MAPPING", {})
app.config.setdefault("AUTH_ROLES_SYNC_AT_LOGIN", False)
app.config.setdefault("AUTH_API_LOGIN_ALLOW_MULTIPLE_PROVIDERS", False)

# LDAP Config
if self.auth_type == AUTH_LDAP:
Expand Down Expand Up @@ -322,11 +323,21 @@ def get_roles_from_keys(self, role_keys: List[str]) -> Set[RoleModelView]:
log.warning(f"Can't find role specified in AUTH_ROLES_MAPPING: {fab_role_name}")
return _roles

@property
def auth_type_provider_name(self):
provider_to_auth_type = {AUTH_DB: "db", AUTH_LDAP: "ldap"}
return provider_to_auth_type.get(self.auth_type)

@property
def get_url_for_registeruser(self):
"""Gets the URL for Register User"""
return url_for(f"{self.registeruser_view.endpoint}.{self.registeruser_view.default_view}")

@property
def get_user_datamodel(self):
"""Gets the User data model"""
return self.user_view.datamodel

@property
def get_register_user_datamodel(self):
"""Gets the Register User data model"""
Expand All @@ -337,6 +348,10 @@ def builtin_roles(self):
"""Get the builtin roles"""
return self._builtin_roles

@property
def api_login_allow_multiple_providers(self):
return self.appbuilder.get_app.config["AUTH_API_LOGIN_ALLOW_MULTIPLE_PROVIDERS"]

@property
def auth_type(self):
"""Get the auth type"""
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Expand Up @@ -93,7 +93,7 @@ install_requires =
deprecated>=1.2.13
dill>=0.2.2, <0.4
flask>=1.1.0, <2.0
flask-appbuilder~=3.4, <4.0.0
flask-appbuilder==3.4.4
aa3pankaj marked this conversation as resolved.
Show resolved Hide resolved
flask-caching>=1.5.0, <2.0.0
flask-login>=0.3, <0.5
flask-wtf>=0.14.3, <0.15
Expand Down