Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move IMPORT_ERROR from DAG related permissions to view related permissions #37292

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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