From 363500072ea25b1c301ed467d3591d746efc1522 Mon Sep 17 00:00:00 2001 From: Pankaj Singh Date: Thu, 3 Feb 2022 18:42:49 +0530 Subject: [PATCH 1/5] added missing provider related methods from FAB --- airflow/www/fab_security/manager.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/airflow/www/fab_security/manager.py b/airflow/www/fab_security/manager.py index 613c69d1125c9..282d682f42b28 100644 --- a/airflow/www/fab_security/manager.py +++ b/airflow/www/fab_security/manager.py @@ -189,6 +189,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: @@ -294,6 +295,11 @@ 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""" @@ -309,6 +315,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""" From d24d4820e2a63fbf9b88ec7f77c59c2c241ab5cc Mon Sep 17 00:00:00 2001 From: Pankaj Singh Date: Fri, 4 Feb 2022 03:08:19 +0530 Subject: [PATCH 2/5] added get_user_datamodel --- airflow/www/fab_security/manager.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/airflow/www/fab_security/manager.py b/airflow/www/fab_security/manager.py index 282d682f42b28..9a8863ceef867 100644 --- a/airflow/www/fab_security/manager.py +++ b/airflow/www/fab_security/manager.py @@ -305,6 +305,11 @@ 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""" From 3af904bd3a50eddb1f15d6dbf3bd481cb63defaa Mon Sep 17 00:00:00 2001 From: Pankaj Singh Date: Fri, 4 Feb 2022 03:18:16 +0530 Subject: [PATCH 3/5] limiting flask-appbuilder to version 3.4.4 --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 573c1ec3b1b25..30b45f9b0da66 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 flask-caching>=1.5.0, <2.0.0 flask-login>=0.3, <0.5 flask-wtf>=0.14.3, <0.15 From 194c309f0ca2e7ce85d6ccddabfb2b3bc683af3a Mon Sep 17 00:00:00 2001 From: Pankaj Singh Date: Wed, 16 Feb 2022 15:49:54 +0530 Subject: [PATCH 4/5] updated comment --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 17dfcaebf4315..8f3570de35ba5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -103,7 +103,7 @@ install_requires = flask>=1.1.0, <2.0 # We are tightly coupled with FAB version because we vendored in part of FAB code related to security manager # This is done as part of preparation to removing FAB as dependency, but we are not ready for it yet - # Every we update FAB version here, please make sure that you review TODO @jhtimmins - please describe + # Every time we update FAB version here, please make sure that you review TODO @jhtimmins - please describe # what to compare and how to sync the changes :) flask-appbuilder==3.4.4 flask-caching>=1.5.0, <2.0.0 From 241322bc1057b70fe4fb45fdbb0aceecf1266145 Mon Sep 17 00:00:00 2001 From: Pankaj Singh Date: Thu, 17 Feb 2022 01:31:54 +0530 Subject: [PATCH 5/5] Update setup.cfg Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com> --- setup.cfg | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 8f3570de35ba5..d28f7f2ab89da 100644 --- a/setup.cfg +++ b/setup.cfg @@ -103,8 +103,9 @@ install_requires = flask>=1.1.0, <2.0 # We are tightly coupled with FAB version because we vendored in part of FAB code related to security manager # This is done as part of preparation to removing FAB as dependency, but we are not ready for it yet - # Every time we update FAB version here, please make sure that you review TODO @jhtimmins - please describe - # what to compare and how to sync the changes :) + # Every time we update FAB version here, please make sure that you review the classes and models in + # `airflow/www/fab_security` with their upstream counterparts. In particular, make sure any breaking changes, + # for example any new methods, are accounted for. flask-appbuilder==3.4.4 flask-caching>=1.5.0, <2.0.0 flask-login>=0.3, <0.5