diff --git a/pkg/controller/workspace/workspace_controller.go b/pkg/controller/workspace/workspace_controller.go index 4a022f85fc7ea0e80a8dd2859d9daec379e3450d..f2c36cdf34803042c9c128b01f247181fa654900 100644 --- a/pkg/controller/workspace/workspace_controller.go +++ b/pkg/controller/workspace/workspace_controller.go @@ -574,10 +574,15 @@ func getWorkspaceAdmin(workspaceName string) *rbac.ClusterRole { APIGroups: []string{"iam.kubesphere.io"}, Resources: []string{"users"}, }, + { + Verbs: []string{"get", "list"}, + APIGroups: []string{"openpitrix.io"}, + Resources: []string{"categories"}, + }, { Verbs: []string{"*"}, APIGroups: []string{"openpitrix.io"}, - Resources: []string{"applications", "apps", "apps/versions", "apps/events", "apps/action", "apps/audits", "repos", "repos/action", "categories", "attachments"}, + Resources: []string{"applications", "apps", "apps/versions", "apps/events", "apps/action", "apps/audits", "repos", "repos/action", "attachments"}, }, } @@ -610,13 +615,13 @@ func getWorkspaceRegular(workspaceName string) *rbac.ClusterRole { { Verbs: []string{"get", "list"}, APIGroups: []string{"openpitrix.io"}, - Resources: []string{"apps/events", "apps/action", "apps/audits"}, + Resources: []string{"apps/events", "apps/action", "apps/audits", "categories"}, }, { Verbs: []string{"*"}, APIGroups: []string{"openpitrix.io"}, - Resources: []string{"applications", "apps", "apps/versions", "repos", "repos/action", "categories", "attachments"}, + Resources: []string{"applications", "apps", "apps/versions", "repos", "repos/action", "attachments"}, }, } diff --git a/pkg/models/iam/am.go b/pkg/models/iam/am.go index e1f4132da2203cf557a456e1aca801bd3b87a13a..3af5b3695c9277c201fe3c48d66e28767516dc16 100644 --- a/pkg/models/iam/am.go +++ b/pkg/models/iam/am.go @@ -481,7 +481,16 @@ func GetUserWorkspaceSimpleRules(workspace, username string) ([]models.SimpleRul return nil, err } - // workspace manager + // cluster-admin + if RulesMatchesRequired(clusterRules, rbacv1.PolicyRule{ + Verbs: []string{"*"}, + APIGroups: []string{"*"}, + Resources: []string{"*"}, + }) { + return GetWorkspaceRoleSimpleRules(workspace, constants.WorkspaceAdmin), nil + } + + // workspaces-manager if RulesMatchesRequired(clusterRules, rbacv1.PolicyRule{ Verbs: []string{"*"}, APIGroups: []string{"*"}, @@ -498,6 +507,7 @@ func GetUserWorkspaceSimpleRules(workspace, username string) ([]models.SimpleRul } return nil, err } + return GetWorkspaceRoleSimpleRules(workspace, workspaceRole.Annotations[constants.DisplayNameAnnotationKey]), nil }