joaopamaral commented on code in PR #40703:
URL: https://github.com/apache/airflow/pull/40703#discussion_r1675984631


##########
airflow/security/permissions.py:
##########
@@ -64,19 +67,38 @@
 DEPRECATED_ACTION_CAN_DAG_READ = "can_dag_read"
 DEPRECATED_ACTION_CAN_DAG_EDIT = "can_dag_edit"
 
-DAG_ACTIONS = {ACTION_CAN_READ, ACTION_CAN_EDIT, ACTION_CAN_DELETE}
+
+class ResourceDetails(TypedDict):
+    """Details of a resource (actions and prefix)."""
+
+    actions: set[str]
+    prefix: str
+
+
+RESOURCE_DETAILS_MAP = {
+    RESOURCE_DAG: ResourceDetails(
+        actions={ACTION_CAN_READ, ACTION_CAN_EDIT, ACTION_CAN_DELETE}, 
prefix=RESOURCE_DAG_PREFIX
+    ),
+    RESOURCE_DAG_RUN: ResourceDetails(
+        actions={ACTION_CAN_READ, ACTION_CAN_CREATE, ACTION_CAN_DELETE, 
ACTION_CAN_ACCESS_MENU},
+        prefix=RESOURCE_DAG_RUN_PREFIX,
+    ),
+}
+PREFIX_RESOURCES_MAP = {
+    prefix: resource for resource, actions in RESOURCE_DETAILS_MAP.items() for 
prefix in actions["prefix"]
+}
 
 
-def resource_name_for_dag(root_dag_id: str) -> str:

Review Comment:
   Thanks for catching this case @shahar1 ! Indeed it was not compatible with 
running only the new FAB.
   
   I've added these 
[changes](https://github.com/apache/airflow/pull/40703/commits/1e80c84479a7180433ef88b877b364b351718ff4)
 to keep the compatibility. And `access_control` works except with DAG Run 
resource:
   
   <img width="1695" alt="image" 
src="https://github.com/user-attachments/assets/a7d8329e-f4e6-4f3e-b16e-6354f948b5ad";>
   



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