diff --git a/dashboard/client/api/rbac.ts b/dashboard/client/api/rbac.ts index fb33b82334..b15b83353e 100644 --- a/dashboard/client/api/rbac.ts +++ b/dashboard/client/api/rbac.ts @@ -1,6 +1,15 @@ import { configStore } from "../config.store"; +import { isArray } from "util"; -export function isAllowedResource(resource: string) { +export function isAllowedResource(resources: string|string[]) { + if (!isArray(resources)) { + resources = [resources]; + } const { allowedResources } = configStore; - return allowedResources.includes(resource) + for (const resource of resources) { + if (!allowedResources.includes(resource)) { + return false; + } + } + return true; } diff --git a/dashboard/client/components/app.tsx b/dashboard/client/components/app.tsx index b07d72749c..220409ec12 100755 --- a/dashboard/client/components/app.tsx +++ b/dashboard/client/components/app.tsx @@ -32,6 +32,7 @@ import { PodLogsDialog } from "./+workloads-pods/pod-logs-dialog"; import { DeploymentScaleDialog } from "./+workloads-deployments/deployment-scale-dialog"; import { CustomResources } from "./+custom-resources/custom-resources"; import { crdRoute } from "./+custom-resources"; +import { isAllowedResource } from "../api/rbac"; @observer class App extends React.Component { @@ -46,7 +47,7 @@ class App extends React.Component { }; render() { - const homeUrl = configStore.isClusterAdmin ? clusterURL() : workloadsURL(); + const homeUrl = (isAllowedResource(["events", "nodes", "pods"])) ? clusterURL() : workloadsURL(); return (