diff --git a/airflow/api_connexion/endpoints/import_error_endpoint.py b/airflow/api_connexion/endpoints/import_error_endpoint.py index 81459b604e9ee..f5554005264c9 100644 --- a/airflow/api_connexion/endpoints/import_error_endpoint.py +++ b/airflow/api_connexion/endpoints/import_error_endpoint.py @@ -28,7 +28,7 @@ import_error_collection_schema, import_error_schema, ) -from airflow.auth.managers.models.resource_details import DagAccessEntity +from airflow.auth.managers.models.resource_details import AccessView from airflow.models.errors import ImportError as ImportErrorModel from airflow.utils.session import NEW_SESSION, provide_session @@ -38,7 +38,7 @@ from airflow.api_connexion.types import APIResponse -@security.requires_access_dag("GET", DagAccessEntity.IMPORT_ERRORS) +@security.requires_access_view(AccessView.IMPORT_ERRORS) @provide_session def get_import_error(*, import_error_id: int, session: Session = NEW_SESSION) -> APIResponse: """Get an import error.""" @@ -52,7 +52,7 @@ def get_import_error(*, import_error_id: int, session: Session = NEW_SESSION) -> return import_error_schema.dump(error) -@security.requires_access_dag("GET", DagAccessEntity.IMPORT_ERRORS) +@security.requires_access_view(AccessView.IMPORT_ERRORS) @format_parameters({"limit": check_limit}) @provide_session def get_import_errors( diff --git a/airflow/auth/managers/models/resource_details.py b/airflow/auth/managers/models/resource_details.py index eb2f81644eb12..fcbee5a2ad299 100644 --- a/airflow/auth/managers/models/resource_details.py +++ b/airflow/auth/managers/models/resource_details.py @@ -68,6 +68,7 @@ class AccessView(Enum): CLUSTER_ACTIVITY = "CLUSTER_ACTIVITY" DOCS = "DOCS" + IMPORT_ERRORS = "IMPORT_ERRORS" JOBS = "JOBS" PLUGINS = "PLUGINS" PROVIDERS = "PROVIDERS" @@ -81,7 +82,6 @@ class DagAccessEntity(Enum): AUDIT_LOG = "AUDIT_LOG" CODE = "CODE" DEPENDENCIES = "DEPENDENCIES" - IMPORT_ERRORS = "IMPORT_ERRORS" RUN = "RUN" SLA_MISS = "SLA_MISS" TASK = "TASK" diff --git a/airflow/providers/fab/auth_manager/fab_auth_manager.py b/airflow/providers/fab/auth_manager/fab_auth_manager.py index dfa53ef78b5b0..131bda179d49e 100644 --- a/airflow/providers/fab/auth_manager/fab_auth_manager.py +++ b/airflow/providers/fab/auth_manager/fab_auth_manager.py @@ -97,7 +97,6 @@ DagAccessEntity.AUDIT_LOG: (RESOURCE_AUDIT_LOG,), DagAccessEntity.CODE: (RESOURCE_DAG_CODE,), DagAccessEntity.DEPENDENCIES: (RESOURCE_DAG_DEPENDENCIES,), - DagAccessEntity.IMPORT_ERRORS: (RESOURCE_IMPORT_ERROR,), DagAccessEntity.RUN: (RESOURCE_DAG_RUN,), DagAccessEntity.SLA_MISS: (RESOURCE_SLA_MISS,), # RESOURCE_TASK_INSTANCE has been originally misused. RESOURCE_TASK_INSTANCE referred to task definition @@ -116,6 +115,7 @@ _MAP_ACCESS_VIEW_TO_FAB_RESOURCE_TYPE = { AccessView.CLUSTER_ACTIVITY: RESOURCE_CLUSTER_ACTIVITY, AccessView.DOCS: RESOURCE_DOCS, + AccessView.IMPORT_ERRORS: RESOURCE_IMPORT_ERROR, AccessView.JOBS: RESOURCE_JOB, AccessView.PLUGINS: RESOURCE_PLUGIN, AccessView.PROVIDERS: RESOURCE_PROVIDER,