Skip to content

Commit

Permalink
Move IMPORT_ERROR from DAG related permissions to view related perm…
Browse files Browse the repository at this point in the history
…issions (#37292)
  • Loading branch information
vincbeck committed Feb 10, 2024
1 parent be756cd commit 28f94f8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions airflow/api_connexion/endpoints/import_error_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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."""
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion airflow/auth/managers/models/resource_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class AccessView(Enum):

CLUSTER_ACTIVITY = "CLUSTER_ACTIVITY"
DOCS = "DOCS"
IMPORT_ERRORS = "IMPORT_ERRORS"
JOBS = "JOBS"
PLUGINS = "PLUGINS"
PROVIDERS = "PROVIDERS"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/fab/auth_manager/fab_auth_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 28f94f8

Please sign in to comment.