fix(dashboard-rbac): use normal rbac when no roles chosen (#23586)

This commit is contained in:
Ville Brofeldt
2023-04-07 09:53:35 +03:00
committed by GitHub
parent 8f0328006b
commit a8230336ff
8 changed files with 107 additions and 44 deletions

View File

@@ -116,9 +116,7 @@ def on_security_exception(self: Any, ex: Exception) -> Response:
# noinspection PyPackageRequirements
def check_dashboard_access(
on_error: Callable[..., Any] = on_security_exception
) -> Callable[..., Any]:
def check_dashboard_access(on_error: Callable[[str], Any]) -> Callable[..., Any]:
def decorator(f: Callable[..., Any]) -> Callable[..., Any]:
@wraps(f)
def wrapper(self: Any, *args: Any, **kwargs: Any) -> Any:
@@ -130,7 +128,7 @@ def check_dashboard_access(
try:
current_app.appbuilder.sm.raise_for_dashboard_access(dashboard)
except DashboardAccessDeniedError as ex:
return on_error(self, ex)
return on_error(str(ex))
except Exception as exception:
raise exception