mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
refactor: Move raise_for_dashboard_access to security manager (#13235)
raise_for_dashboard_access is part of dashboard and cannot be overridden by a security manager.
This commit is contained in:
@@ -19,7 +19,7 @@ from functools import wraps
|
||||
from typing import Any, Callable, Dict, Iterator, Union
|
||||
|
||||
from contextlib2 import contextmanager
|
||||
from flask import Response
|
||||
from flask import current_app, Response
|
||||
|
||||
from superset import is_feature_enabled
|
||||
from superset.dashboards.commands.exceptions import DashboardAccessDeniedError
|
||||
@@ -87,15 +87,12 @@ def check_dashboard_access(
|
||||
def decorator(f: Callable[..., Any]) -> Callable[..., Any]:
|
||||
@wraps(f)
|
||||
def wrapper(self: Any, *args: Any, **kwargs: Any) -> Any:
|
||||
from superset.models.dashboard import (
|
||||
Dashboard,
|
||||
raise_for_dashboard_access,
|
||||
)
|
||||
from superset.models.dashboard import Dashboard
|
||||
|
||||
dashboard = Dashboard.get(str(kwargs["dashboard_id_or_slug"]))
|
||||
if is_feature_enabled("DASHBOARD_RBAC"):
|
||||
try:
|
||||
raise_for_dashboard_access(dashboard)
|
||||
current_app.appbuilder.sm.raise_for_dashboard_access(dashboard)
|
||||
except DashboardAccessDeniedError as ex:
|
||||
return on_error(self, ex)
|
||||
except Exception as exception:
|
||||
|
||||
Reference in New Issue
Block a user