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


##########
airflow/auth/managers/base_auth_manager.py:
##########
@@ -63,6 +68,69 @@ def get_user_id(self) -> str:
     def is_logged_in(self) -> bool:
         """Return whether the user is logged in."""
 
+    @abstractmethod
+    def is_authorized(
+        self,
+        action: ResourceAction,
+        resource_type: str,
+        resource_details: ResourceDetails | None = None,
+        user: BaseUser | None = None,
+    ) -> bool:
+        """
+        Return whether the user is authorized to perform a given action.
+
+        .. code-block:: python
+
+            # Check whether the logged-in user has permission to read the DAG 
"my_dag_id"
+            get_auth_manager().is_authorized(
+                Action.GET,
+                Resource.DAG,
+                ResourceDetails(
+                    id="my_dag_id",
+                ),
+            )
+
+        :param action: the action to perform
+        :param resource_type: the type of resource the user attempts to 
perform the action on
+        :param resource_details: optional details about the resource itself
+        :param user: the user to perform the action on. If not provided (or 
None), it uses the current user
+        """
+
+    def is_all_authorized(
+        self,
+        actions: Sequence[AuthorizedAction],
+    ) -> bool:
+        """
+        Wrapper around `is_authorized` to check whether the user is authorized 
to perform several actions.
+
+        :param actions: the list of actions to check. Each item represents the 
list of parameters of
+            `is_authorized`
+        """
+        return all(
+            self.is_authorized(
+                action=action.action,
+                resource_type=action.resource_type,
+                resource_details=action.resource_details,
+                user=action.user,
+            )
+            for action in actions
+        )
+
+    def _get_root_dag_id(self, dag_id: str) -> str:
+        """
+        Return the root DAG id in case of sub DAG, return the DAG id otherwise.
+
+        :param dag_id: the DAG id
+        """
+        if "." in dag_id:

Review Comment:
   Sounds good to me then :)



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to