This is an automated email from the ASF dual-hosted git repository.

vincbeck pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 556791b13d Implement `is_authorized()` in auth manager (#33213)
556791b13d is described below

commit 556791b13d4e4c10f95f3cb4c6079f548447e1b8
Author: Vincent <[email protected]>
AuthorDate: Mon Sep 25 10:13:22 2023 -0400

    Implement `is_authorized()` in auth manager (#33213)
---
 airflow/auth/managers/base_auth_manager.py         | 114 +++++-
 airflow/auth/managers/fab/fab_auth_manager.py      | 247 ++++++++++++-
 airflow/auth/managers/models/base_user.py          |   6 +
 .../models/{base_user.py => resource_details.py}   |  40 +-
 airflow/www/auth.py                                | 153 ++++++--
 airflow/www/views.py                               | 406 +++------------------
 docs/apache-airflow/empty_plugin/empty_plugin.py   |   9 +-
 tests/auth/managers/fab/test_fab_auth_manager.py   | 214 ++++++++++-
 tests/auth/managers/test_base_auth_manager.py      |  74 +++-
 tests/www/test_auth.py                             |   8 +-
 tests/www/views/conftest.py                        |   1 -
 11 files changed, 841 insertions(+), 431 deletions(-)

diff --git a/airflow/auth/managers/base_auth_manager.py 
b/airflow/auth/managers/base_auth_manager.py
index d626f36810..29695dae12 100644
--- a/airflow/auth/managers/base_auth_manager.py
+++ b/airflow/auth/managers/base_auth_manager.py
@@ -18,7 +18,7 @@
 from __future__ import annotations
 
 from abc import abstractmethod
-from typing import TYPE_CHECKING
+from typing import TYPE_CHECKING, Literal
 
 from airflow.exceptions import AirflowException
 from airflow.utils.log.logging_mixin import LoggingMixin
@@ -27,9 +27,16 @@ if TYPE_CHECKING:
     from flask import Flask
 
     from airflow.auth.managers.models.base_user import BaseUser
+    from airflow.auth.managers.models.resource_details import (
+        ConnectionDetails,
+        DagAccessEntity,
+        DagDetails,
+    )
     from airflow.cli.cli_config import CLICommand
     from airflow.www.security_manager import AirflowSecurityManagerV2
 
+ResourceMethod = Literal["GET", "POST", "PUT", "DELETE"]
+
 
 class BaseAuthManager(LoggingMixin):
     """
@@ -70,6 +77,111 @@ class BaseAuthManager(LoggingMixin):
     def is_logged_in(self) -> bool:
         """Return whether the user is logged in."""
 
+    @abstractmethod
+    def is_authorized_configuration(
+        self,
+        *,
+        method: ResourceMethod,
+        user: BaseUser | None = None,
+    ) -> bool:
+        """
+        Return whether the user is authorized to perform a given action on 
configuration.
+
+        :param method: the method to perform
+        :param user: the user to perform the action on. If not provided (or 
None), it uses the current user
+        """
+
+    @abstractmethod
+    def is_authorized_cluster_activity(
+        self,
+        *,
+        method: ResourceMethod,
+        user: BaseUser | None = None,
+    ) -> bool:
+        """
+        Return whether the user is authorized to perform a given action on the 
cluster activity.
+
+        :param method: the method to perform
+        :param user: the user to perform the action on. If not provided (or 
None), it uses the current user
+        """
+
+    @abstractmethod
+    def is_authorized_connection(
+        self,
+        *,
+        method: ResourceMethod,
+        connection_details: ConnectionDetails | None = None,
+        user: BaseUser | None = None,
+    ) -> bool:
+        """
+        Return whether the user is authorized to perform a given action on a 
connection.
+
+        :param method: the method to perform
+        :param connection_details: optional details about the connection
+        :param user: the user to perform the action on. If not provided (or 
None), it uses the current user
+        """
+
+    @abstractmethod
+    def is_authorized_dag(
+        self,
+        *,
+        method: ResourceMethod,
+        dag_access_entity: DagAccessEntity | None = None,
+        dag_details: DagDetails | None = None,
+        user: BaseUser | None = None,
+    ) -> bool:
+        """
+        Return whether the user is authorized to perform a given action on a 
DAG.
+
+        :param method: the method to perform
+        :param dag_access_entity: the kind of DAG information the 
authorization request is about.
+            If not provided, the authorization request is about the DAG itself
+        :param dag_details: optional details about the DAG
+        :param user: the user to perform the action on. If not provided (or 
None), it uses the current user
+        """
+
+    @abstractmethod
+    def is_authorized_dataset(
+        self,
+        *,
+        method: ResourceMethod,
+        user: BaseUser | None = None,
+    ) -> bool:
+        """
+        Return whether the user is authorized to perform a given action on a 
dataset.
+
+        :param method: the method to perform
+        :param user: the user to perform the action on. If not provided (or 
None), it uses the current user
+        """
+
+    @abstractmethod
+    def is_authorized_variable(
+        self,
+        *,
+        method: ResourceMethod,
+        user: BaseUser | None = None,
+    ) -> bool:
+        """
+        Return whether the user is authorized to perform a given action on a 
variable.
+
+        :param method: the method to perform
+        :param user: the user to perform the action on. If not provided (or 
None), it uses the current user
+        """
+
+    @abstractmethod
+    def is_authorized_website(
+        self,
+        *,
+        user: BaseUser | None = None,
+    ) -> bool:
+        """
+        Return whether the user is authorized to access the read-only state of 
the installation.
+
+        This includes the homepage, the list of installed plugins, the list of 
providers and list of triggers.
+
+        :param user: the user to perform the action on. If not provided (or 
None), it uses the current user
+        """
+
     @abstractmethod
     def get_url_login(self, **kwargs) -> str:
         """Return the login page url."""
diff --git a/airflow/auth/managers/fab/fab_auth_manager.py 
b/airflow/auth/managers/fab/fab_auth_manager.py
index be50c57470..9c2c5643b6 100644
--- a/airflow/auth/managers/fab/fab_auth_manager.py
+++ b/airflow/auth/managers/fab/fab_auth_manager.py
@@ -20,23 +20,69 @@ from __future__ import annotations
 import warnings
 from typing import TYPE_CHECKING
 
-from airflow.auth.managers.base_auth_manager import BaseAuthManager
+from flask import url_for
+from sqlalchemy import select
+
+from airflow.auth.managers.base_auth_manager import BaseAuthManager, 
ResourceMethod
 from airflow.auth.managers.fab.cli_commands.definition import (
     ROLES_COMMANDS,
     SYNC_PERM_COMMAND,
     USERS_COMMANDS,
 )
+from airflow.auth.managers.models.resource_details import ConnectionDetails, 
DagAccessEntity, DagDetails
 from airflow.cli.cli_config import (
     GroupCommand,
 )
 from airflow.exceptions import AirflowException
+from airflow.models import DagModel
+from airflow.security.permissions import (
+    ACTION_CAN_ACCESS_MENU,
+    ACTION_CAN_CREATE,
+    ACTION_CAN_DELETE,
+    ACTION_CAN_EDIT,
+    ACTION_CAN_READ,
+    RESOURCE_AUDIT_LOG,
+    RESOURCE_CLUSTER_ACTIVITY,
+    RESOURCE_CONFIG,
+    RESOURCE_CONNECTION,
+    RESOURCE_DAG,
+    RESOURCE_DAG_CODE,
+    RESOURCE_DAG_DEPENDENCIES,
+    RESOURCE_DAG_PREFIX,
+    RESOURCE_DAG_RUN,
+    RESOURCE_DATASET,
+    RESOURCE_TASK_INSTANCE,
+    RESOURCE_TASK_LOG,
+    RESOURCE_VARIABLE,
+    RESOURCE_WEBSITE,
+    RESOURCE_XCOM,
+)
 
 if TYPE_CHECKING:
     from airflow.auth.managers.fab.models import User
+    from airflow.auth.managers.models.base_user import BaseUser
     from airflow.cli.cli_config import (
         CLICommand,
     )
 
+_MAP_METHOD_NAME_TO_FAB_ACTION_NAME: dict[ResourceMethod, str] = {
+    "POST": ACTION_CAN_CREATE,
+    "GET": ACTION_CAN_READ,
+    "PUT": ACTION_CAN_EDIT,
+    "DELETE": ACTION_CAN_DELETE,
+}
+
+_MAP_DAG_ACCESS_ENTITY_TO_FAB_RESOURCE_TYPE = {
+    DagAccessEntity.AUDIT_LOG: RESOURCE_AUDIT_LOG,
+    DagAccessEntity.CODE: RESOURCE_DAG_CODE,
+    DagAccessEntity.DATASET: RESOURCE_DATASET,
+    DagAccessEntity.DEPENDENCIES: RESOURCE_DAG_DEPENDENCIES,
+    DagAccessEntity.RUN: RESOURCE_DAG_RUN,
+    DagAccessEntity.TASK_INSTANCE: RESOURCE_TASK_INSTANCE,
+    DagAccessEntity.TASK_LOGS: RESOURCE_TASK_LOG,
+    DagAccessEntity.XCOM: RESOURCE_XCOM,
+}
+
 
 class FabAuthManager(BaseAuthManager):
     """
@@ -93,6 +139,67 @@ class FabAuthManager(BaseAuthManager):
         """Return whether the user is logged in."""
         return not self.get_user().is_anonymous
 
+    def is_authorized_configuration(self, *, method: ResourceMethod, user: 
BaseUser | None = None) -> bool:
+        return self._is_authorized(method=method, 
resource_type=RESOURCE_CONFIG, user=user)
+
+    def is_authorized_cluster_activity(self, *, method: ResourceMethod, user: 
BaseUser | None = None) -> bool:
+        return self._is_authorized(method=method, 
resource_type=RESOURCE_CLUSTER_ACTIVITY, user=user)
+
+    def is_authorized_connection(
+        self,
+        *,
+        method: ResourceMethod,
+        connection_details: ConnectionDetails | None = None,
+        user: BaseUser | None = None,
+    ) -> bool:
+        return self._is_authorized(method=method, 
resource_type=RESOURCE_CONNECTION, user=user)
+
+    def is_authorized_dag(
+        self,
+        *,
+        method: ResourceMethod,
+        dag_access_entity: DagAccessEntity | None = None,
+        dag_details: DagDetails | None = None,
+        user: BaseUser | None = None,
+    ) -> bool:
+        """
+        Return whether the user is authorized to access the dag.
+
+        There are multiple scenarios:
+
+        1. ``dag_access`` is not provided which means the user wants to access 
the DAG itself and not a sub
+        entity (e.g. DAG runs).
+        2. ``dag_access`` is provided which means the user wants to access a 
sub entity of the DAG
+        (e.g. DAG runs).
+            a. If ``method`` is GET, then check the user has READ permissions 
on the DAG and the sub entity
+            b. Else, check the user has EDIT permissions on the DAG and 
``method`` on the sub entity
+
+        :param method: The method to authorize.
+        :param dag_access_entity: The dag access entity.
+        :param dag_details: The dag details.
+        :param user: The user.
+        """
+        if not dag_access_entity:
+            # Scenario 1
+            return self._is_authorized_dag(method=method, 
dag_details=dag_details, user=user)
+        else:
+            # Scenario 2
+            resource_type = self._get_fab_resource_type(dag_access_entity)
+            dag_method: ResourceMethod = "GET" if method == "GET" else "PUT"
+
+            return self._is_authorized_dag(
+                method=dag_method, dag_details=dag_details, user=user
+            ) and self._is_authorized(method=method, 
resource_type=resource_type, user=user)
+
+    def is_authorized_dataset(self, *, method: ResourceMethod, user: BaseUser 
| None = None) -> bool:
+        return self._is_authorized(method=method, 
resource_type=RESOURCE_DATASET, user=user)
+
+    def is_authorized_variable(self, *, method: ResourceMethod, user: BaseUser 
| None = None) -> bool:
+        return self._is_authorized(method=method, 
resource_type=RESOURCE_VARIABLE, user=user)
+
+    def is_authorized_website(self, *, user: BaseUser | None = None) -> bool:
+        return self._is_authorized(method="GET", 
resource_type=RESOURCE_WEBSITE, user=user)
+
     def get_security_manager_override_class(self) -> type:
         """Return the security manager override."""
         from airflow.auth.managers.fab.security_manager.override import 
FabAirflowSecurityManagerOverride
@@ -115,29 +222,147 @@ class FabAuthManager(BaseAuthManager):
 
         return FabAirflowSecurityManagerOverride  # default choice
 
-    def url_for(self, *args, **kwargs):
-        """Wrapper to allow mocking without having to import at the top of the 
file."""
-        from flask import url_for
-
-        return url_for(*args, **kwargs)
-
     def get_url_login(self, **kwargs) -> str:
         """Return the login page url."""
         if not self.security_manager.auth_view:
             raise AirflowException("`auth_view` not defined in the security 
manager.")
         if "next_url" in kwargs and kwargs["next_url"]:
-            return 
self.url_for(f"{self.security_manager.auth_view.endpoint}.login", 
next=kwargs["next_url"])
+            return 
url_for(f"{self.security_manager.auth_view.endpoint}.login", 
next=kwargs["next_url"])
         else:
-            return 
self.url_for(f"{self.security_manager.auth_view.endpoint}.login")
+            return url_for(f"{self.security_manager.auth_view.endpoint}.login")
 
     def get_url_logout(self):
         """Return the logout page url."""
         if not self.security_manager.auth_view:
             raise AirflowException("`auth_view` not defined in the security 
manager.")
-        return 
self.url_for(f"{self.security_manager.auth_view.endpoint}.logout")
+        return url_for(f"{self.security_manager.auth_view.endpoint}.logout")
 
     def get_url_user_profile(self) -> str | None:
         """Return the url to a page displaying info about the current user."""
         if not self.security_manager.user_view:
             return None
-        return 
self.url_for(f"{self.security_manager.user_view.endpoint}.userinfo")
+        return url_for(f"{self.security_manager.user_view.endpoint}.userinfo")
+
+    def _is_authorized(
+        self,
+        *,
+        method: ResourceMethod,
+        resource_type: str,
+        user: BaseUser | None = None,
+    ) -> bool:
+        """
+        Return whether the user is authorized to perform a given action.
+
+        :param method: the method to perform
+        :param resource_type: the type of resource the user attempts to 
perform the action on
+        :param user: the user to perform the action on. If not provided (or 
None), it uses the current user
+
+        :meta private:
+        """
+        if not user:
+            user = self.get_user()
+
+        fab_action = self._get_fab_action(method)
+        user_permissions = self._get_user_permissions(user)
+
+        return (fab_action, resource_type) in user_permissions
+
+    def _is_authorized_dag(
+        self,
+        method: ResourceMethod,
+        dag_details: DagDetails | None = None,
+        user: BaseUser | None = None,
+    ) -> bool:
+        """
+        Return whether the user is authorized to perform a given action on a 
DAG.
+
+        :param method: the method to perform
+        :param dag_details: optional details about the DAG
+        :param user: the user to perform the action on. If not provided (or 
None), it uses the current user
+
+        :meta private:
+        """
+        is_global_authorized = self._is_authorized(method=method, 
resource_type=RESOURCE_DAG, user=user)
+        if is_global_authorized:
+            return True
+
+        if dag_details and dag_details.id:
+            # Check whether the user has permissions to access a specific DAG
+            resource_dag_name = self._resource_name_for_dag(dag_details.id)
+            return self._is_authorized(method=method, 
resource_type=resource_dag_name, user=user)
+
+        return False
+
+    @staticmethod
+    def _get_fab_action(method: ResourceMethod) -> str:
+        """
+        Convert the method to a FAB action.
+
+        :param method: the method to convert
+
+        :meta private:
+        """
+        if method not in _MAP_METHOD_NAME_TO_FAB_ACTION_NAME:
+            raise AirflowException(f"Unknown method: {method}")
+        return _MAP_METHOD_NAME_TO_FAB_ACTION_NAME[method]
+
+    @staticmethod
+    def _get_fab_resource_type(dag_access_entity: DagAccessEntity):
+        """
+        Convert a DAG access entity to a FAB resource type.
+
+        :param dag_access_entity: the DAG access entity
+
+        :meta private:
+        """
+        if dag_access_entity not in 
_MAP_DAG_ACCESS_ENTITY_TO_FAB_RESOURCE_TYPE:
+            raise AirflowException(f"Unknown DAG access entity: 
{dag_access_entity}")
+        return _MAP_DAG_ACCESS_ENTITY_TO_FAB_RESOURCE_TYPE[dag_access_entity]
+
+    def _resource_name_for_dag(self, dag_id: str) -> str:
+        """
+        Returns the FAB resource name for a DAG id.
+
+        :param dag_id: the DAG id
+
+        :meta private:
+        """
+        root_dag_id = self._get_root_dag_id(dag_id)
+        if root_dag_id == RESOURCE_DAG:
+            return root_dag_id
+        if root_dag_id.startswith(RESOURCE_DAG_PREFIX):
+            return root_dag_id
+        return f"{RESOURCE_DAG_PREFIX}{root_dag_id}"
+
+    @staticmethod
+    def _get_user_permissions(user: BaseUser):
+        """
+        Return the user permissions.
+
+        ACTION_CAN_READ and ACTION_CAN_ACCESS_MENU are merged into because 
they are very similar.
+        We can assume that if a user has permissions to read variables, they 
also have permissions to access
+        the menu "Variables".
+
+        :param user: the user to get permissions for
+
+        :meta private:
+        """
+        return [
+            (ACTION_CAN_READ if perm[0] == ACTION_CAN_ACCESS_MENU else 
perm[0], perm[1])
+            for perm in user.perms
+        ]
+
+    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
+
+        :meta private:
+        """
+        if "." in dag_id:
+            dm = self.security_manager.appbuilder.get_session.scalar(
+                select(DagModel.dag_id, 
DagModel.root_dag_id).where(DagModel.dag_id == dag_id).limit(1)
+            )
+            return dm.root_dag_id or dm.dag_id
+        return dag_id
diff --git a/airflow/auth/managers/models/base_user.py 
b/airflow/auth/managers/models/base_user.py
index 329846881a..7bc17cc240 100644
--- a/airflow/auth/managers/models/base_user.py
+++ b/airflow/auth/managers/models/base_user.py
@@ -18,6 +18,7 @@
 from __future__ import annotations
 
 from abc import abstractmethod
+from typing import Any
 
 
 class BaseUser:
@@ -37,6 +38,11 @@ class BaseUser:
     def is_anonymous(self) -> bool:
         ...
 
+    @property
+    @abstractmethod
+    def perms(self) -> Any:
+        ...
+
     @abstractmethod
     def get_id(self) -> str:
         ...
diff --git a/airflow/auth/managers/models/base_user.py 
b/airflow/auth/managers/models/resource_details.py
similarity index 60%
copy from airflow/auth/managers/models/base_user.py
copy to airflow/auth/managers/models/resource_details.py
index 329846881a..51cdc59793 100644
--- a/airflow/auth/managers/models/base_user.py
+++ b/airflow/auth/managers/models/resource_details.py
@@ -17,26 +17,32 @@
 # under the License.
 from __future__ import annotations
 
-from abc import abstractmethod
+from dataclasses import dataclass
+from enum import Enum
 
 
-class BaseUser:
-    """User model interface."""
+@dataclass
+class ConnectionDetails:
+    """Represents the details of a connection."""
 
-    @property
-    def is_authenticated(self) -> bool:
-        return not self.is_anonymous
+    conn_id: str
 
-    @property
-    @abstractmethod
-    def is_active(self) -> bool:
-        ...
 
-    @property
-    @abstractmethod
-    def is_anonymous(self) -> bool:
-        ...
+@dataclass
+class DagDetails:
+    """Represents the details of a DAG."""
 
-    @abstractmethod
-    def get_id(self) -> str:
-        ...
+    id: str
+
+
+class DagAccessEntity(Enum):
+    """Enum of DAG entities the user tries to access."""
+
+    AUDIT_LOG = "AUDIT_LOG"
+    CODE = "CODE"
+    DATASET = "DATASET"
+    DEPENDENCIES = "DEPENDENCIES"
+    RUN = "RUN"
+    TASK_INSTANCE = "TASK_INSTANCE"
+    TASK_LOGS = "TASK_LOGS"
+    XCOM = "XCOM"
diff --git a/airflow/www/auth.py b/airflow/www/auth.py
index d7821f14f2..c943779ab0 100644
--- a/airflow/www/auth.py
+++ b/airflow/www/auth.py
@@ -18,14 +18,23 @@ from __future__ import annotations
 
 import logging
 from functools import wraps
-from typing import Callable, Sequence, TypeVar, cast
+from typing import TYPE_CHECKING, Callable, TypeVar, cast
 
-from flask import current_app, flash, g, redirect, render_template, request
+from flask import flash, g, redirect, render_template, request
 
+from airflow.auth.managers.models.resource_details import (
+    ConnectionDetails,
+    DagAccessEntity,
+    DagDetails,
+)
 from airflow.configuration import conf
 from airflow.utils.net import get_hostname
 from airflow.www.extensions.init_auth_manager import get_auth_manager
 
+if TYPE_CHECKING:
+    from airflow.auth.managers.base_auth_manager import ResourceMethod
+    from airflow.models import Connection
+
 T = TypeVar("T", bound=Callable)
 
 log = logging.getLogger(__name__)
@@ -35,16 +44,100 @@ def get_access_denied_message():
     return conf.get("webserver", "access_denied_message")
 
 
-def has_access(permissions: Sequence[tuple[str, str]] | None = None) -> 
Callable[[T], T]:
-    """Factory for decorator that checks current user's permissions against 
required permissions."""
+def _has_access_no_details(is_authorized_callback: Callable[[], bool]) -> 
Callable[[T], T]:
+    """
+    Generic Decorator that checks current user's permissions against required 
permissions.
+
+    This works only for resources with no details. This function is used in 
some ``has_access_`` functions
+    below.
+
+    :param is_authorized_callback: callback to execute to figure whether the 
user authorized to access
+        the resource?
+    """
+
+    def has_access_decorator(func: T):
+        @wraps(func)
+        def decorated(*args, **kwargs):
+            return _has_access(
+                is_authorized=is_authorized_callback(),
+                func=func,
+                args=args,
+                kwargs=kwargs,
+            )
+
+        return cast(T, decorated)
+
+    return has_access_decorator
+
 
-    def requires_access_decorator(func: T):
+def _has_access(*, is_authorized: bool, func: Callable, args, kwargs):
+    """
+    Define the behavior whether the user is authorized to access the resource.
+
+    :param is_authorized: whether the user is authorized to access the resource
+    :param func: the function to call if the user is authorized
+    :param args: the arguments of ``func``
+    :param kwargs: the keyword arguments ``func``
+
+    :meta private:
+    """
+    if is_authorized:
+        return func(*args, **kwargs)
+    elif get_auth_manager().is_logged_in() and not g.user.perms:
+        return (
+            render_template(
+                "airflow/no_roles_permissions.html",
+                hostname=get_hostname() if conf.getboolean("webserver", 
"EXPOSE_HOSTNAME") else "redact",
+                logout_url=get_auth_manager().get_url_logout(),
+            ),
+            403,
+        )
+    else:
+        access_denied = get_access_denied_message()
+        flash(access_denied, "danger")
+    return redirect(get_auth_manager().get_url_login(next=request.url))
+
+
+def has_access_cluster_activity(method: ResourceMethod) -> Callable[[T], T]:
+    return _has_access_no_details(lambda: 
get_auth_manager().is_authorized_cluster_activity(method=method))
+
+
+def has_access_configuration(method: ResourceMethod) -> Callable[[T], T]:
+    return _has_access_no_details(lambda: 
get_auth_manager().is_authorized_configuration(method=method))
+
+
+def has_access_connection(method: ResourceMethod) -> Callable[[T], T]:
+    def has_access_decorator(func: T):
         @wraps(func)
         def decorated(*args, **kwargs):
-            __tracebackhide__ = True  # Hide from pytest traceback.
+            connections: set[Connection] = set(args[1])
+            connections_details = [
+                ConnectionDetails(conn_id=connection.conn_id) for connection 
in connections
+            ]
+            is_authorized = all(
+                [
+                    get_auth_manager().is_authorized_connection(
+                        method=method, connection_details=connection_details
+                    )
+                    for connection_details in connections_details
+                ]
+            )
+            return _has_access(
+                is_authorized=is_authorized,
+                func=func,
+                args=args,
+                kwargs=kwargs,
+            )
+
+        return cast(T, decorated)
 
-            appbuilder = current_app.appbuilder
+    return has_access_decorator
 
+
+def has_access_dag(method: ResourceMethod, access_entity: DagAccessEntity | 
None = None) -> Callable[[T], T]:
+    def has_access_decorator(func: T):
+        @wraps(func)
+        def decorated(*args, **kwargs):
             dag_id_kwargs = kwargs.get("dag_id")
             dag_id_args = request.args.get("dag_id")
             dag_id_form = request.form.get("dag_id")
@@ -72,24 +165,34 @@ def has_access(permissions: Sequence[tuple[str, str]] | 
None = None) -> Callable
                 )
             dag_id = unique_dag_ids.pop() if unique_dag_ids else None
 
-            if appbuilder.sm.check_authorization(permissions, dag_id):
-                return func(*args, **kwargs)
-            elif get_auth_manager().is_logged_in() and not g.user.perms:
-                return (
-                    render_template(
-                        "airflow/no_roles_permissions.html",
-                        hostname=get_hostname()
-                        if conf.getboolean("webserver", "EXPOSE_HOSTNAME")
-                        else "redact",
-                        logout_url=get_auth_manager().get_url_logout(),
-                    ),
-                    403,
-                )
-            else:
-                access_denied = get_access_denied_message()
-                flash(access_denied, "danger")
-            return redirect(get_auth_manager().get_url_login(next=request.url))
+            is_authorized = get_auth_manager().is_authorized_dag(
+                method=method,
+                dag_access_entity=access_entity,
+                dag_details=None if not dag_id else DagDetails(id=dag_id),
+            )
+
+            return _has_access(
+                is_authorized=is_authorized,
+                func=func,
+                args=args,
+                kwargs=kwargs,
+            )
 
         return cast(T, decorated)
 
-    return requires_access_decorator
+    return has_access_decorator
+
+
+def has_access_dataset(method: ResourceMethod) -> Callable[[T], T]:
+    """Decorator that checks current user's permissions against required 
permissions for datasets."""
+    return _has_access_no_details(lambda: 
get_auth_manager().is_authorized_dataset(method=method))
+
+
+def has_access_variable(method: ResourceMethod) -> Callable[[T], T]:
+    """Decorator that checks current user's permissions against required 
permissions for variables."""
+    return _has_access_no_details(lambda: 
get_auth_manager().is_authorized_variable(method=method))
+
+
+def has_access_website() -> Callable[[T], T]:
+    """Decorator that checks current user's permissions to access the 
website."""
+    return _has_access_no_details(lambda: 
get_auth_manager().is_authorized_website())
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 2ea074bc9b..f3511fc41c 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -81,6 +81,7 @@ from airflow.api.common.mark_tasks import (
     set_dag_run_state_to_success,
     set_state,
 )
+from airflow.auth.managers.models.resource_details import DagAccessEntity
 from airflow.configuration import AIRFLOW_CONFIG, conf
 from airflow.datasets import Dataset
 from airflow.exceptions import (
@@ -728,11 +729,7 @@ class Airflow(AirflowBaseView):
         return flask.json.jsonify(airflow_health_status)
 
     @expose("/home")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_WEBSITE),
-        ]
-    )
+    @auth.has_access_website()
     def index(self):
         """Home view."""
         from airflow.models.dag import DagOwnerAttributes
@@ -1040,7 +1037,7 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/datasets")
-    @auth.has_access([(permissions.ACTION_CAN_READ, 
permissions.RESOURCE_DATASET)])
+    @auth.has_access_dataset("GET")
     def datasets(self):
         """Datasets view."""
         state_color_mapping = State.state_color.copy()
@@ -1051,11 +1048,7 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/cluster_activity")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, 
permissions.RESOURCE_CLUSTER_ACTIVITY),
-        ]
-    )
+    @auth.has_access_cluster_activity("GET")
     def cluster_activity(self):
         """Cluster Activity view."""
         state_color_mapping = State.state_color.copy()
@@ -1069,7 +1062,7 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/next_run_datasets_summary", methods=["POST"])
-    @auth.has_access([(permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG)])
+    @auth.has_access_dag("GET")
     @provide_session
     def next_run_datasets_summary(self, session: Session = NEW_SESSION):
         """Next run info for dataset triggered DAGs."""
@@ -1104,12 +1097,7 @@ class Airflow(AirflowBaseView):
         return flask.json.jsonify(dataset_triggered_next_run_info)
 
     @expose("/dag_stats", methods=["POST"])
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG_RUN),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.RUN)
     @provide_session
     def dag_stats(self, session: Session = NEW_SESSION):
         """Dag statistics."""
@@ -1141,13 +1129,7 @@ class Airflow(AirflowBaseView):
         return flask.json.jsonify(payload)
 
     @expose("/task_stats", methods=["POST"])
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG_RUN),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.TASK_INSTANCE)
     @provide_session
     def task_stats(self, session: Session = NEW_SESSION):
         """Task Statistics."""
@@ -1248,12 +1230,7 @@ class Airflow(AirflowBaseView):
         return flask.json.jsonify(payload)
 
     @expose("/last_dagruns", methods=["POST"])
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG_RUN),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.RUN)
     @provide_session
     def last_dagruns(self, session: Session = NEW_SESSION):
         """Last DAG runs."""
@@ -1313,23 +1290,12 @@ class Airflow(AirflowBaseView):
         return flask.json.jsonify(resp)
 
     @expose("/code")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG_CODE),
-        ]
-    )
     def legacy_code(self):
         """Redirect from url param."""
         return redirect(url_for("Airflow.code", **sanitize_args(request.args)))
 
     @expose("/dags/<string:dag_id>/code")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG_CODE),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.CODE)
     @provide_session
     def code(self, dag_id, session: Session = NEW_SESSION):
         """Dag Code."""
@@ -1342,23 +1308,12 @@ class Airflow(AirflowBaseView):
         return redirect(url_for("Airflow.grid", **kwargs))
 
     @expose("/dag_details")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG_RUN),
-        ]
-    )
     def legacy_dag_details(self):
         """Redirect from url param."""
         return redirect(url_for("Airflow.dag_details", 
**sanitize_args(request.args)))
 
     @expose("/dags/<string:dag_id>/details")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG_RUN),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.RUN)
     @provide_session
     def dag_details(self, dag_id, session: Session = NEW_SESSION):
         """Get Dag details."""
@@ -1434,12 +1389,7 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/rendered-templates")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.TASK_INSTANCE)
     @action_logging
     @provide_session
     def rendered_templates(self, session):
@@ -1558,12 +1508,7 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/rendered-k8s")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.TASK_INSTANCE)
     @action_logging
     @provide_session
     def rendered_k8s(self, *, session: Session = NEW_SESSION):
@@ -1626,13 +1571,8 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/get_logs_with_metadata")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_LOG),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.TASK_INSTANCE)
+    @auth.has_access_dag("GET", DagAccessEntity.TASK_LOGS)
     @action_logging
     @provide_session
     def get_logs_with_metadata(self, session: Session = NEW_SESSION):
@@ -1713,13 +1653,7 @@ class Airflow(AirflowBaseView):
             return {"message": error_messages, "error": True, "metadata": 
metadata}
 
     @expose("/log")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_LOG),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.TASK_LOGS)
     @action_logging
     @provide_session
     def log(self, session: Session = NEW_SESSION):
@@ -1764,13 +1698,7 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/redirect_to_external_log")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_LOG),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.TASK_LOGS)
     @action_logging
     @provide_session
     def redirect_to_external_log(self, session: Session = NEW_SESSION):
@@ -1802,12 +1730,7 @@ class Airflow(AirflowBaseView):
         return redirect(url)
 
     @expose("/task")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.TASK_INSTANCE)
     @action_logging
     @provide_session
     def task(self, session: Session = NEW_SESSION):
@@ -1933,13 +1856,7 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/xcom")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_XCOM),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.XCOM)
     @action_logging
     @provide_session
     def xcom(self, session: Session = NEW_SESSION):
@@ -1986,11 +1903,7 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/delete", methods=["POST"])
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_DELETE, permissions.RESOURCE_DAG),
-        ]
-    )
+    @auth.has_access_dag("DELETE")
     @action_logging
     def delete(self):
         """Deletes DAG."""
@@ -2021,12 +1934,7 @@ class Airflow(AirflowBaseView):
         return redirect(origin)
 
     @expose("/dags/<string:dag_id>/trigger", methods=["POST", "GET"])
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_CREATE, permissions.RESOURCE_DAG_RUN),
-        ]
-    )
+    @auth.has_access_dag("POST", DagAccessEntity.RUN)
     @action_logging
     @provide_session
     def trigger(self, dag_id: str, session: Session = NEW_SESSION):
@@ -2314,12 +2222,7 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/clear", methods=["POST"])
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
+    @auth.has_access_dag("PUT", DagAccessEntity.TASK_INSTANCE)
     @action_logging
     @provide_session
     def clear(self, *, session: Session = NEW_SESSION):
@@ -2409,12 +2312,7 @@ class Airflow(AirflowBaseView):
         return response
 
     @expose("/dagrun_clear", methods=["POST"])
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
+    @auth.has_access_dag("PUT", DagAccessEntity.TASK_INSTANCE)
     @action_logging
     @provide_session
     def dagrun_clear(self, *, session: Session = NEW_SESSION):
@@ -2439,12 +2337,7 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/blocked", methods=["POST"])
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG_RUN),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.RUN)
     @provide_session
     def blocked(self, session: Session = NEW_SESSION):
         """Mark Dag Blocked."""
@@ -2559,12 +2452,7 @@ class Airflow(AirflowBaseView):
             return htmlsafe_json_dumps(details, separators=(",", ":"))
 
     @expose("/dagrun_failed", methods=["POST"])
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG_RUN),
-        ]
-    )
+    @auth.has_access_dag("PUT", DagAccessEntity.RUN)
     @action_logging
     def dagrun_failed(self):
         """Mark DagRun failed."""
@@ -2574,12 +2462,7 @@ class Airflow(AirflowBaseView):
         return self._mark_dagrun_state_as_failed(dag_id, dag_run_id, confirmed)
 
     @expose("/dagrun_success", methods=["POST"])
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG_RUN),
-        ]
-    )
+    @auth.has_access_dag("PUT", DagAccessEntity.RUN)
     @action_logging
     def dagrun_success(self):
         """Mark DagRun success."""
@@ -2589,12 +2472,7 @@ class Airflow(AirflowBaseView):
         return self._mark_dagrun_state_as_success(dag_id, dag_run_id, 
confirmed)
 
     @expose("/dagrun_queued", methods=["POST"])
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG_RUN),
-        ]
-    )
+    @auth.has_access_dag("PUT", DagAccessEntity.RUN)
     @action_logging
     def dagrun_queued(self):
         """Queue DagRun so tasks that haven't run yet can be started."""
@@ -2677,12 +2555,7 @@ class Airflow(AirflowBaseView):
         return redirect(origin)
 
     @expose("/confirm", methods=["GET"])
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
+    @auth.has_access_dag("PUT", DagAccessEntity.TASK_INSTANCE)
     @action_logging
     def confirm(self):
         """Show confirmation page for marking tasks as success or failed."""
@@ -2779,12 +2652,7 @@ class Airflow(AirflowBaseView):
         return response
 
     @expose("/failed", methods=["POST"])
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
+    @auth.has_access_dag("PUT", DagAccessEntity.TASK_INSTANCE)
     @action_logging
     def failed(self):
         """Mark task or task_group as failed."""
@@ -2835,12 +2703,7 @@ class Airflow(AirflowBaseView):
             )
 
     @expose("/success", methods=["POST"])
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
+    @auth.has_access_dag("PUT", DagAccessEntity.TASK_INSTANCE)
     @action_logging
     def success(self):
         """Mark task or task_group as success."""
@@ -2891,13 +2754,6 @@ class Airflow(AirflowBaseView):
             )
 
     @expose("/dags/<string:dag_id>")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_LOG),
-        ]
-    )
     @gzipped
     @action_logging
     def dag(self, dag_id):
@@ -2906,13 +2762,6 @@ class Airflow(AirflowBaseView):
         return redirect(url_for("Airflow.grid", **kwargs))
 
     @expose("/tree")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_LOG),
-        ]
-    )
     @gzipped
     @action_logging
     def legacy_tree(self):
@@ -2920,13 +2769,7 @@ class Airflow(AirflowBaseView):
         return redirect(url_for("Airflow.grid", **sanitize_args(request.args)))
 
     @expose("/dags/<string:dag_id>/grid")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_LOG),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.TASK_INSTANCE)
     @gzipped
     @action_logging
     @provide_session
@@ -2987,12 +2830,6 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/calendar")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
     @gzipped
     @action_logging
     def legacy_calendar(self):
@@ -3000,12 +2837,7 @@ class Airflow(AirflowBaseView):
         return redirect(url_for("Airflow.calendar", 
**sanitize_args(request.args)))
 
     @expose("/dags/<string:dag_id>/calendar")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.RUN)
     @gzipped
     @action_logging
     @provide_session
@@ -3121,13 +2953,6 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/graph")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_LOG),
-        ]
-    )
     @gzipped
     @action_logging
     def legacy_graph(self):
@@ -3135,13 +2960,6 @@ class Airflow(AirflowBaseView):
         return redirect(url_for("Airflow.graph", 
**sanitize_args(request.args)))
 
     @expose("/dags/<string:dag_id>/graph")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_LOG),
-        ]
-    )
     @gzipped
     @action_logging
     @provide_session
@@ -3163,24 +2981,13 @@ class Airflow(AirflowBaseView):
         return redirect(url_for("Airflow.grid", **kwargs))
 
     @expose("/duration")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
     @action_logging
     def legacy_duration(self):
         """Redirect from url param."""
         return redirect(url_for("Airflow.duration", 
**sanitize_args(request.args)))
 
     @expose("/dags/<string:dag_id>/duration")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.TASK_INSTANCE)
     @action_logging
     @provide_session
     def duration(self, dag_id: str, session: Session = NEW_SESSION):
@@ -3327,24 +3134,13 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/tries")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
     @action_logging
     def legacy_tries(self):
         """Redirect from url param."""
         return redirect(url_for("Airflow.tries", 
**sanitize_args(request.args)))
 
     @expose("/dags/<string:dag_id>/tries")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.TASK_INSTANCE)
     @action_logging
     @provide_session
     def tries(self, dag_id: str, session: Session = NEW_SESSION):
@@ -3421,24 +3217,13 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/landing_times")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
     @action_logging
     def legacy_landing_times(self):
         """Redirect from url param."""
         return redirect(url_for("Airflow.landing_times", 
**sanitize_args(request.args)))
 
     @expose("/dags/<string:dag_id>/landing-times")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.TASK_INSTANCE)
     @action_logging
     @provide_session
     def landing_times(self, dag_id: str, session: Session = NEW_SESSION):
@@ -3528,11 +3313,7 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/paused", methods=["POST"])
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG),
-        ]
-    )
+    @auth.has_access_dag("PUT")
     @action_logging
     def paused(self):
         """Toggle paused."""
@@ -3542,24 +3323,13 @@ class Airflow(AirflowBaseView):
         return "OK"
 
     @expose("/gantt")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
     @action_logging
     def legacy_gantt(self):
         """Redirect from url param."""
         return redirect(url_for("Airflow.gantt", 
**sanitize_args(request.args)))
 
     @expose("/dags/<string:dag_id>/gantt")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.TASK_INSTANCE)
     @action_logging
     @provide_session
     def gantt(self, dag_id: str, session: Session = NEW_SESSION):
@@ -3575,12 +3345,7 @@ class Airflow(AirflowBaseView):
         return redirect(url_for("Airflow.grid", **kwargs))
 
     @expose("/extra_links")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.TASK_INSTANCE)
     @action_logging
     @provide_session
     def extra_links(self, *, session: Session = NEW_SESSION):
@@ -3636,13 +3401,7 @@ class Airflow(AirflowBaseView):
             return {"url": None, "error": f"No URL found for {link_name}"}, 404
 
     @expose("/object/graph_data")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_LOG),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.TASK_INSTANCE)
     @gzipped
     @action_logging
     @provide_session
@@ -3672,12 +3431,7 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/object/task_instances")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.TASK_INSTANCE)
     @action_logging
     def task_instances(self):
         """Shows task instances."""
@@ -3699,12 +3453,7 @@ class Airflow(AirflowBaseView):
         return flask.json.jsonify(task_instances)
 
     @expose("/object/grid_data")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.TASK_INSTANCE)
     def grid_data(self):
         """Returns grid data."""
         dag_id = request.args.get("dag_id")
@@ -3757,11 +3506,7 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/object/historical_metrics_data")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, 
permissions.RESOURCE_CLUSTER_ACTIVITY),
-        ]
-    )
+    @auth.has_access_cluster_activity("GET")
     def historical_metrics_data(self):
         """Returns cluster activity historical metrics."""
         start_date = _safe_parse_datetime(request.args.get("start_date"))
@@ -3820,7 +3565,7 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/object/next_run_datasets/<string:dag_id>")
-    @auth.has_access([(permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG)])
+    @auth.has_access_dag("GET", DagAccessEntity.DATASET)
     def next_run_datasets(self, dag_id):
         """Returns datasets necessary, and their status, for the next dag 
run."""
         dag = get_airflow_app().dag_bag.get_dag(dag_id)
@@ -3863,11 +3608,7 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/object/dataset_dependencies")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, 
permissions.RESOURCE_DAG_DEPENDENCIES),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.DEPENDENCIES)
     def dataset_dependencies(self):
         """Returns dataset dependencies graph."""
         nodes_dict: dict[str, Any] = {}
@@ -3902,7 +3643,7 @@ class Airflow(AirflowBaseView):
         )
 
     @expose("/object/datasets_summary")
-    @auth.has_access([(permissions.ACTION_CAN_READ, 
permissions.RESOURCE_DATASET)])
+    @auth.has_access_dataset("GET")
     def datasets_summary(self):
         """
         Get a summary of datasets.
@@ -4010,23 +3751,12 @@ class Airflow(AirflowBaseView):
         return send_from_directory(get_airflow_app().static_folder, 
"robots.txt")
 
     @expose("/audit_log")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_AUDIT_LOG),
-        ]
-    )
     def legacy_audit_log(self):
         """Redirect from url param."""
         return redirect(url_for("Airflow.audit_log", 
**sanitize_args(request.args)))
 
     @expose("/dags/<string:dag_id>/audit_log")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_AUDIT_LOG),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.AUDIT_LOG)
     @provide_session
     def audit_log(self, dag_id: str, session: Session = NEW_SESSION):
         dag = get_airflow_app().dag_bag.get_dag(dag_id, session=session)
@@ -4099,11 +3829,7 @@ class ConfigurationView(AirflowBaseView):
     ]
 
     @expose("/configuration")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_CONFIG),
-        ]
-    )
+    @auth.has_access_configuration("GET")
     def conf(self):
         """Shows configuration."""
         raw = request.args.get("raw") == "true"
@@ -4612,14 +4338,10 @@ class ConnectionModelView(AirflowModelView):
         return self._edit_columns
 
     @action("muldelete", "Delete", "Are you sure you want to delete selected 
records?", single=False)
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG),
-        ]
-    )
-    def action_muldelete(self, items):
+    @auth.has_access_connection("DELETE")
+    def action_muldelete(self, connections):
         """Multiple delete."""
-        self.datamodel.delete_all(items)
+        self.datamodel.delete_all(connections)
         self.update_redirect()
         return redirect(self.get_redirect())
 
@@ -4630,12 +4352,8 @@ class ConnectionModelView(AirflowModelView):
         single=False,
     )
     @provide_session
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_CREATE, permissions.RESOURCE_CONNECTION),
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_CONNECTION),
-        ]
-    )
+    @auth.has_access_connection("POST")
+    @auth.has_access_connection("GET")
     def action_mulduplicate(self, connections, session: Session = NEW_SESSION):
         """Duplicate Multiple connections."""
         for selected_conn in connections:
@@ -4811,11 +4529,7 @@ class PluginView(AirflowBaseView):
     ]
 
     @expose("/plugin")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_PLUGIN),
-        ]
-    )
+    @auth.has_access_website()
     def list(self):
         """List loaded plugins."""
         plugins_manager.ensure_plugins_loaded()
@@ -4863,11 +4577,7 @@ class ProviderView(AirflowBaseView):
     ]
 
     @expose("/provider")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_PROVIDER),
-        ]
-    )
+    @auth.has_access_website()
     def list(self):
         """List providers."""
         providers_manager = ProvidersManager()
@@ -5140,7 +4850,7 @@ class VariableModelView(AirflowModelView):
         return response
 
     @expose("/varimport", methods=["POST"])
-    @auth.has_access([(permissions.ACTION_CAN_CREATE, 
permissions.RESOURCE_VARIABLE)])
+    @auth.has_access_variable("POST")
     @action_logging(event=f"{permissions.RESOURCE_VARIABLE.lower()}.varimport")
     @provide_session
     def varimport(self, session):
@@ -5986,7 +5696,7 @@ class 
TaskInstanceModelView(AirflowPrivilegeVerifierModelView):
 class AutocompleteView(AirflowBaseView):
     """View to provide autocomplete results."""
 
-    @auth.has_access([(permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG)])
+    @auth.has_access_dag("GET")
     @provide_session
     @expose("/dagmodel/autocomplete")
     def autocomplete(self, session: Session = NEW_SESSION):
@@ -6046,11 +5756,7 @@ class DagDependenciesView(AirflowBaseView):
     edges: list[dict[str, str]] = []
 
     @expose("/dag-dependencies")
-    @auth.has_access(
-        [
-            (permissions.ACTION_CAN_READ, 
permissions.RESOURCE_DAG_DEPENDENCIES),
-        ]
-    )
+    @auth.has_access_dag("GET", DagAccessEntity.DEPENDENCIES)
     @gzipped
     @action_logging
     def list(self):
diff --git a/docs/apache-airflow/empty_plugin/empty_plugin.py 
b/docs/apache-airflow/empty_plugin/empty_plugin.py
index abf7b6d802..6686eb1b67 100644
--- a/docs/apache-airflow/empty_plugin/empty_plugin.py
+++ b/docs/apache-airflow/empty_plugin/empty_plugin.py
@@ -22,8 +22,7 @@ from flask import Blueprint
 from flask_appbuilder import BaseView, expose
 
 from airflow.plugins_manager import AirflowPlugin
-from airflow.security import permissions
-from airflow.www.auth import has_access
+from airflow.www.auth import has_access_website
 
 
 class EmptyPluginView(BaseView):
@@ -32,11 +31,7 @@ class EmptyPluginView(BaseView):
     default_view = "index"
 
     @expose("/")
-    @has_access(
-        [
-            (permissions.ACTION_CAN_READ, permissions.RESOURCE_WEBSITE),
-        ]
-    )
+    @has_access_website()
     def index(self):
         """Create default view"""
         return self.render_template("empty_plugin/index.html", name="Empty 
Plugin")
diff --git a/tests/auth/managers/fab/test_fab_auth_manager.py 
b/tests/auth/managers/fab/test_fab_auth_manager.py
index 3d2bcfed67..85a13ad178 100644
--- a/tests/auth/managers/fab/test_fab_auth_manager.py
+++ b/tests/auth/managers/fab/test_fab_auth_manager.py
@@ -16,6 +16,7 @@
 # under the License.
 from __future__ import annotations
 
+from itertools import chain
 from unittest import mock
 from unittest.mock import Mock
 
@@ -24,9 +25,34 @@ import pytest
 from airflow.auth.managers.fab.fab_auth_manager import FabAuthManager
 from airflow.auth.managers.fab.models import User
 from airflow.auth.managers.fab.security_manager.override import 
FabAirflowSecurityManagerOverride
+from airflow.auth.managers.models.resource_details import DagAccessEntity, 
DagDetails
 from airflow.exceptions import AirflowException
+from airflow.security.permissions import (
+    ACTION_CAN_ACCESS_MENU,
+    ACTION_CAN_CREATE,
+    ACTION_CAN_DELETE,
+    ACTION_CAN_EDIT,
+    ACTION_CAN_READ,
+    RESOURCE_CLUSTER_ACTIVITY,
+    RESOURCE_CONFIG,
+    RESOURCE_CONNECTION,
+    RESOURCE_DAG,
+    RESOURCE_DAG_RUN,
+    RESOURCE_DATASET,
+    RESOURCE_TASK_INSTANCE,
+    RESOURCE_VARIABLE,
+    RESOURCE_WEBSITE,
+)
 from airflow.www.security_appless import ApplessAirflowSecurityManager
 
+IS_AUTHORIZED_METHODS_SIMPLE = {
+    "is_authorized_configuration": RESOURCE_CONFIG,
+    "is_authorized_cluster_activity": RESOURCE_CLUSTER_ACTIVITY,
+    "is_authorized_connection": RESOURCE_CONNECTION,
+    "is_authorized_dataset": RESOURCE_DATASET,
+    "is_authorized_variable": RESOURCE_VARIABLE,
+}
+
 
 @pytest.fixture
 def auth_manager():
@@ -112,6 +138,186 @@ class TestFabAuthManager:
 
         assert auth_manager.is_logged_in() is False
 
+    @pytest.mark.parametrize(
+        "api_name, method, user_permissions, expected_result",
+        chain(
+            *[
+                (
+                    # With permission
+                    (
+                        api_name,
+                        "POST",
+                        [(ACTION_CAN_CREATE, resource_type)],
+                        True,
+                    ),
+                    # With permission
+                    (
+                        api_name,
+                        "GET",
+                        [(ACTION_CAN_READ, resource_type)],
+                        True,
+                    ),
+                    # With permission (with several user permissions)
+                    (
+                        api_name,
+                        "DELETE",
+                        [(ACTION_CAN_DELETE, resource_type), 
(ACTION_CAN_CREATE, "resource_test")],
+                        True,
+                    ),
+                    # With permission (testing that ACTION_CAN_ACCESS_MENU 
gives GET permissions)
+                    (
+                        api_name,
+                        "GET",
+                        [(ACTION_CAN_ACCESS_MENU, resource_type)],
+                        True,
+                    ),
+                    # Without permission
+                    (
+                        api_name,
+                        "POST",
+                        [(ACTION_CAN_READ, resource_type), (ACTION_CAN_CREATE, 
"resource_test")],
+                        False,
+                    ),
+                )
+                for api_name, resource_type in 
IS_AUTHORIZED_METHODS_SIMPLE.items()
+            ]
+        ),
+    )
+    def test_is_authorized(self, api_name, method, user_permissions, 
expected_result, auth_manager):
+        user = Mock()
+        user.perms = user_permissions
+        result = getattr(auth_manager, api_name)(
+            method=method,
+            user=user,
+        )
+        assert result == expected_result
+
+    @pytest.mark.parametrize(
+        "method, dag_access_entity, dag_details, user_permissions, 
expected_result",
+        [
+            # Scenario 1 #
+            # With global permissions on Dags
+            (
+                "GET",
+                None,
+                None,
+                [(ACTION_CAN_READ, RESOURCE_DAG)],
+                True,
+            ),
+            # On specific DAG with global permissions on Dags
+            (
+                "GET",
+                None,
+                DagDetails(id="test_dag_id"),
+                [(ACTION_CAN_READ, RESOURCE_DAG)],
+                True,
+            ),
+            # With permission on a specific DAG
+            (
+                "GET",
+                None,
+                DagDetails(id="test_dag_id"),
+                [(ACTION_CAN_READ, "DAG:test_dag_id"), (ACTION_CAN_READ, 
"DAG:test_dag_id2")],
+                True,
+            ),
+            # Without permission on a specific DAG (wrong method)
+            (
+                "POST",
+                None,
+                DagDetails(id="test_dag_id"),
+                [(ACTION_CAN_READ, "DAG:test_dag_id")],
+                False,
+            ),
+            # Without permission on a specific DAG
+            (
+                "GET",
+                None,
+                DagDetails(id="test_dag_id2"),
+                [(ACTION_CAN_READ, "DAG:test_dag_id")],
+                False,
+            ),
+            # Without permission on DAGs
+            (
+                "GET",
+                None,
+                None,
+                [(ACTION_CAN_READ, "resource_test")],
+                False,
+            ),
+            # Scenario 2 #
+            # With global permissions on DAGs
+            (
+                "GET",
+                DagAccessEntity.RUN,
+                DagDetails(id="test_dag_id"),
+                [(ACTION_CAN_READ, RESOURCE_DAG), (ACTION_CAN_READ, 
RESOURCE_DAG_RUN)],
+                True,
+            ),
+            # With read permissions on a specific DAG
+            (
+                "GET",
+                DagAccessEntity.TASK_INSTANCE,
+                DagDetails(id="test_dag_id"),
+                [(ACTION_CAN_READ, "DAG:test_dag_id"), (ACTION_CAN_READ, 
RESOURCE_TASK_INSTANCE)],
+                True,
+            ),
+            # With edit permissions on a specific DAG and read on the DAG 
access entity
+            (
+                "POST",
+                DagAccessEntity.RUN,
+                DagDetails(id="test_dag_id"),
+                [(ACTION_CAN_EDIT, "DAG:test_dag_id"), (ACTION_CAN_CREATE, 
RESOURCE_DAG_RUN)],
+                True,
+            ),
+            # Without permissions to edit the DAG
+            (
+                "POST",
+                DagAccessEntity.RUN,
+                DagDetails(id="test_dag_id"),
+                [(ACTION_CAN_CREATE, RESOURCE_DAG_RUN)],
+                False,
+            ),
+            # Without read permissions on a specific DAG
+            (
+                "GET",
+                DagAccessEntity.TASK_LOGS,
+                DagDetails(id="test_dag_id"),
+                [(ACTION_CAN_READ, RESOURCE_TASK_INSTANCE)],
+                False,
+            ),
+        ],
+    )
+    def test_is_authorized_dag(
+        self, method, dag_access_entity, dag_details, user_permissions, 
expected_result, auth_manager
+    ):
+        user = Mock()
+        user.perms = user_permissions
+        result = auth_manager.is_authorized_dag(
+            method=method, dag_access_entity=dag_access_entity, 
dag_details=dag_details, user=user
+        )
+        assert result == expected_result
+
+    @pytest.mark.parametrize(
+        "user_permissions, expected_result",
+        [
+            # With permission
+            (
+                [(ACTION_CAN_READ, RESOURCE_WEBSITE)],
+                True,
+            ),
+            # Without permission
+            (
+                [(ACTION_CAN_READ, "resource_test"), (ACTION_CAN_CREATE, 
RESOURCE_WEBSITE)],
+                False,
+            ),
+        ],
+    )
+    def test_is_authorized_website(self, user_permissions, expected_result, 
auth_manager):
+        user = Mock()
+        user.perms = user_permissions
+        result = auth_manager.is_authorized_website(user=user)
+        assert result == expected_result
+
     def 
test_get_security_manager_override_class_return_fab_security_manager_override(self,
 auth_manager):
         assert auth_manager.get_security_manager_override_class() is 
FabAirflowSecurityManagerOverride
 
@@ -119,14 +325,14 @@ class TestFabAuthManager:
         with pytest.raises(AirflowException, match="`auth_view` not defined in 
the security manager."):
             auth_manager.get_url_login()
 
-    @mock.patch.object(FabAuthManager, "url_for")
+    @mock.patch("airflow.auth.managers.fab.fab_auth_manager.url_for")
     def test_get_url_login(self, mock_url_for, auth_manager):
         auth_manager.security_manager.auth_view = Mock()
         auth_manager.security_manager.auth_view.endpoint = "test_endpoint"
         auth_manager.get_url_login()
         mock_url_for.assert_called_once_with("test_endpoint.login")
 
-    @mock.patch.object(FabAuthManager, "url_for")
+    @mock.patch("airflow.auth.managers.fab.fab_auth_manager.url_for")
     def test_get_url_login_with_next(self, mock_url_for, auth_manager):
         auth_manager.security_manager.auth_view = Mock()
         auth_manager.security_manager.auth_view.endpoint = "test_endpoint"
@@ -137,7 +343,7 @@ class TestFabAuthManager:
         with pytest.raises(AirflowException, match="`auth_view` not defined in 
the security manager."):
             auth_manager.get_url_logout()
 
-    @mock.patch.object(FabAuthManager, "url_for")
+    @mock.patch("airflow.auth.managers.fab.fab_auth_manager.url_for")
     def test_get_url_logout(self, mock_url_for, auth_manager):
         auth_manager.security_manager.auth_view = Mock()
         auth_manager.security_manager.auth_view.endpoint = "test_endpoint"
@@ -147,7 +353,7 @@ class TestFabAuthManager:
     def test_get_url_user_profile_when_auth_view_not_defined(self, 
auth_manager):
         assert auth_manager.get_url_user_profile() is None
 
-    @mock.patch.object(FabAuthManager, "url_for")
+    @mock.patch("airflow.auth.managers.fab.fab_auth_manager.url_for")
     def test_get_url_user_profile(self, mock_url_for, auth_manager):
         expected_url = "test_url"
         mock_url_for.return_value = expected_url
diff --git a/tests/auth/managers/test_base_auth_manager.py 
b/tests/auth/managers/test_base_auth_manager.py
index c506133b43..1ff8dcfbbf 100644
--- a/tests/auth/managers/test_base_auth_manager.py
+++ b/tests/auth/managers/test_base_auth_manager.py
@@ -16,27 +16,79 @@
 # under the License.
 from __future__ import annotations
 
+from typing import TYPE_CHECKING
+
 import pytest
 
-from airflow.auth.managers.base_auth_manager import BaseAuthManager
+from airflow.auth.managers.base_auth_manager import BaseAuthManager, 
ResourceMethod
 from airflow.exceptions import AirflowException
 from airflow.www.security_appless import ApplessAirflowSecurityManager
 from airflow.www.security_manager import AirflowSecurityManagerV2
 
+if TYPE_CHECKING:
+    from airflow.auth.managers.models.base_user import BaseUser
+    from airflow.auth.managers.models.resource_details import 
ConnectionDetails, DagAccessEntity, DagDetails
 
[email protected]
-def auth_manager():
-    class EmptyAuthManager(BaseAuthManager):
-        def get_user_name(self) -> str:
-            raise NotImplementedError()
 
-        def is_logged_in(self) -> bool:
-            raise NotImplementedError()
+class EmptyAuthManager(BaseAuthManager):
+    def get_user_name(self) -> str:
+        raise NotImplementedError()
+
+    def get_user(self) -> BaseUser:
+        raise NotImplementedError()
+
+    def get_user_id(self) -> str:
+        raise NotImplementedError()
+
+    def is_authorized_configuration(self, *, method: ResourceMethod, user: 
BaseUser | None = None) -> bool:
+        raise NotImplementedError()
+
+    def is_authorized_cluster_activity(self, *, method: ResourceMethod, user: 
BaseUser | None = None) -> bool:
+        raise NotImplementedError()
+
+    def is_authorized_connection(
+        self,
+        *,
+        method: ResourceMethod,
+        connection_details: ConnectionDetails | None = None,
+        user: BaseUser | None = None,
+    ) -> bool:
+        raise NotImplementedError()
+
+    def is_authorized_dag(
+        self,
+        *,
+        method: ResourceMethod,
+        dag_access_entity: DagAccessEntity | None = None,
+        dag_details: DagDetails | None = None,
+        user: BaseUser | None = None,
+    ) -> bool:
+        raise NotImplementedError()
 
-        def get_url_login(self, **kwargs) -> str:
-            raise NotImplementedError()
+    def is_authorized_dataset(self, *, method: ResourceMethod, user: BaseUser 
| None = None) -> bool:
+        raise NotImplementedError()
 
-    # noinspection PyTypeChecker
+    def is_authorized_variable(self, *, method: ResourceMethod, user: BaseUser 
| None = None) -> bool:
+        raise NotImplementedError()
+
+    def is_authorized_website(self, *, user: BaseUser | None = None) -> bool:
+        raise NotImplementedError()
+
+    def is_logged_in(self) -> bool:
+        raise NotImplementedError()
+
+    def get_url_login(self, **kwargs) -> str:
+        raise NotImplementedError()
+
+    def get_url_logout(self) -> str:
+        raise NotImplementedError()
+
+    def get_url_user_profile(self) -> str | None:
+        raise NotImplementedError()
+
+
[email protected]
+def auth_manager():
     return EmptyAuthManager(None)
 
 
diff --git a/tests/www/test_auth.py b/tests/www/test_auth.py
index 5ff6768e65..0a522200d0 100644
--- a/tests/www/test_auth.py
+++ b/tests/www/test_auth.py
@@ -64,7 +64,7 @@ def test_dag_id_consistency(
     fail: bool,
 ):
     with app.test_request_context() as mock_context:
-        from airflow.www.auth import has_access
+        from airflow.www.auth import has_access_dag
 
         mock_context.request.args = {"dag_id": dag_id_args} if dag_id_args 
else {}
         kwargs = {"dag_id": dag_id_kwargs} if dag_id_kwargs else {}
@@ -79,10 +79,10 @@ def test_dag_id_consistency(
             role_name="limited-role",
             permissions=[(permissions.ACTION_CAN_READ, 
permissions.RESOURCE_DAG)],
         ) as user:
-            with patch("airflow.www.security_manager.g") as mock_g:
-                mock_g.user = user
+            with 
patch("airflow.auth.managers.fab.fab_auth_manager.FabAuthManager.get_user") as 
mock_get_user:
+                mock_get_user.return_value = user
 
-                @has_access(permissions=[(permissions.ACTION_CAN_READ, 
permissions.RESOURCE_DAG)])
+                @has_access_dag("GET")
                 def test_func(**kwargs):
                     return True
 
diff --git a/tests/www/views/conftest.py b/tests/www/views/conftest.py
index 25e3a6d20a..1bde030388 100644
--- a/tests/www/views/conftest.py
+++ b/tests/www/views/conftest.py
@@ -112,7 +112,6 @@ def app(examples_dag_bag):
 
 @pytest.fixture()
 def admin_client(app):
-
     return client_with_login(app, username="test_admin", password="test_admin")
 
 

Reply via email to