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


##########
providers/src/airflow/providers/fab/www/security_manager.py:
##########
@@ -0,0 +1,310 @@
+# Licensed to the Apache Software Foundation (ASF) under one

Review Comment:
   File copied from `airflow/www/security_manager.py`



##########
providers/src/airflow/providers/fab/www/session.py:
##########
@@ -0,0 +1,41 @@
+# Licensed to the Apache Software Foundation (ASF) under one

Review Comment:
   Copy of `airflow/www/session.py`



##########
providers/src/airflow/providers/fab/auth_manager/fab_auth_manager.py:
##########
@@ -398,6 +400,32 @@ def get_permitted_dag_ids(
                         resources.add(resource)
         return 
set(session.scalars(select(DagModel.dag_id).where(DagModel.dag_id.in_(resources))))
 
+    def filter_permitted_menu_items(self, menu_items: list[MenuItem]) -> 
list[MenuItem]:

Review Comment:
   Implementation copied from the interface



##########
providers/src/airflow/providers/fab/www/extensions/init_session.py:
##########
@@ -0,0 +1,64 @@
+# Licensed to the Apache Software Foundation (ASF) under one

Review Comment:
   File copied from `airflow/www/extensions/init_session.py`



##########
providers/src/airflow/providers/fab/www/views.py:
##########
@@ -0,0 +1,66 @@
+#

Review Comment:
   Copied from `airflow/www/views.py`



##########
providers/src/airflow/providers/fab/www/utils.py:
##########
@@ -0,0 +1,933 @@
+#

Review Comment:
   Copied from `airflow/www/utils.py`



##########
airflow/auth/managers/base_auth_manager.py:
##########
@@ -395,47 +400,6 @@ def _is_permitted_dag_id(method: ResourceMethod, methods: 
Container[ResourceMeth
             if _is_permitted_dag_id("GET", methods, dag_id) or 
_is_permitted_dag_id("PUT", methods, dag_id)
         }
 
-    def filter_permitted_menu_items(self, menu_items: list[MenuItem]) -> 
list[MenuItem]:
-        """
-        Filter menu items based on user permissions.
-
-        :param menu_items: list of all menu items
-        """
-        items = filter(
-            lambda item: 
self.security_manager.has_access(ACTION_CAN_ACCESS_MENU, item.name), menu_items
-        )
-        accessible_items = []
-        for menu_item in items:
-            menu_item_copy = MenuItem(
-                **{
-                    **menu_item.__dict__,
-                    "childs": [],
-                }
-            )
-            if menu_item.childs:
-                accessible_children = []
-                for child in menu_item.childs:
-                    if 
self.security_manager.has_access(ACTION_CAN_ACCESS_MENU, child.name):
-                        accessible_children.append(child)
-                menu_item_copy.childs = accessible_children
-            accessible_items.append(menu_item_copy)
-        return accessible_items
-
-    @cached_property
-    def security_manager(self) -> AirflowSecurityManagerV2:

Review Comment:
   Remove the concept of security manager from the interface because it is very 
specific to Flask



-- 
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