vincbeck commented on code in PR #33901:
URL: https://github.com/apache/airflow/pull/33901#discussion_r1311999855


##########
airflow/www/extensions/init_appbuilder.py:
##########
@@ -660,15 +661,24 @@ def _process_inner_views(self):
 
 def init_appbuilder(app) -> AirflowAppBuilder:
     """Init `Flask App Builder 
<https://flask-appbuilder.readthedocs.io/en/latest/>`__."""
+    from airflow.auth.managers.fab.security_manager.override import 
FabAirflowSecurityManagerOverride
     from airflow.www.security import AirflowSecurityManager
 
-    security_manager_class = app.config.get("SECURITY_MANAGER_CLASS") or 
AirflowSecurityManager
+    sm_from_config = app.config.get("SECURITY_MANAGER_CLASS")
+    if sm_from_config:
+        if not issubclass(sm_from_config, AirflowSecurityManager):
+            raise Exception(
+                """Your CUSTOM_SECURITY_MANAGER must extend 
FabAirflowSecurityManagerOverride,
+                 not FAB's own security manager."""
+            )
+        if not issubclass(sm_from_config, FabAirflowSecurityManagerOverride):
+            warnings.warn(
+                "Please make your custom security manager inherit from "
+                "FabAirflowSecurityManagerOverride instead of 
AirflowSecurityManager.",
+                DeprecationWarning,
+            )

Review Comment:
   We should move this piece of code inside 
`get_security_manager_override_class` of `FabAuthManager`



##########
airflow/www/extensions/init_appbuilder.py:
##########
@@ -660,15 +661,24 @@ def _process_inner_views(self):
 
 def init_appbuilder(app) -> AirflowAppBuilder:
     """Init `Flask App Builder 
<https://flask-appbuilder.readthedocs.io/en/latest/>`__."""
+    from airflow.auth.managers.fab.security_manager.override import 
FabAirflowSecurityManagerOverride
     from airflow.www.security import AirflowSecurityManager
 
-    security_manager_class = app.config.get("SECURITY_MANAGER_CLASS") or 
AirflowSecurityManager
+    sm_from_config = app.config.get("SECURITY_MANAGER_CLASS")
+    if sm_from_config:
+        if not issubclass(sm_from_config, AirflowSecurityManager):
+            raise Exception(
+                """Your CUSTOM_SECURITY_MANAGER must extend 
FabAirflowSecurityManagerOverride,
+                 not FAB's own security manager."""
+            )
+        if not issubclass(sm_from_config, FabAirflowSecurityManagerOverride):
+            warnings.warn(
+                "Please make your custom security manager inherit from "
+                "FabAirflowSecurityManagerOverride instead of 
AirflowSecurityManager.",
+                DeprecationWarning,
+            )
 
-    if not issubclass(security_manager_class, AirflowSecurityManager):
-        raise Exception(
-            """Your CUSTOM_SECURITY_MANAGER must now extend 
AirflowSecurityManager,
-             not FAB's security manager."""
-        )
+    security_manager_class = sm_from_config or 
FabAirflowSecurityManagerOverride

Review Comment:
   It should be as simple as that. We need to modify the method 
`get_security_manager_override_class` of `BaseAuthManager` to return 
`AirflowSecurityManager` by default
   
   ```suggestion
       security_manager_class = 
get_auth_manager().get_security_manager_override_class()
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to