未验证 提交 24cbc083 编写于 作者: K KubeSphere CI Bot 提交者: GitHub

Merge pull request #1341 from wansir/policy-rules

refine iam policy rules
...@@ -574,10 +574,15 @@ func getWorkspaceAdmin(workspaceName string) *rbac.ClusterRole { ...@@ -574,10 +574,15 @@ func getWorkspaceAdmin(workspaceName string) *rbac.ClusterRole {
APIGroups: []string{"iam.kubesphere.io"}, APIGroups: []string{"iam.kubesphere.io"},
Resources: []string{"users"}, Resources: []string{"users"},
}, },
{
Verbs: []string{"get", "list"},
APIGroups: []string{"openpitrix.io"},
Resources: []string{"categories"},
},
{ {
Verbs: []string{"*"}, Verbs: []string{"*"},
APIGroups: []string{"openpitrix.io"}, 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 { ...@@ -610,13 +615,13 @@ func getWorkspaceRegular(workspaceName string) *rbac.ClusterRole {
{ {
Verbs: []string{"get", "list"}, Verbs: []string{"get", "list"},
APIGroups: []string{"openpitrix.io"}, APIGroups: []string{"openpitrix.io"},
Resources: []string{"apps/events", "apps/action", "apps/audits"}, Resources: []string{"apps/events", "apps/action", "apps/audits", "categories"},
}, },
{ {
Verbs: []string{"*"}, Verbs: []string{"*"},
APIGroups: []string{"openpitrix.io"}, 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"},
}, },
} }
......
...@@ -480,7 +480,16 @@ func GetUserWorkspaceSimpleRules(workspace, username string) ([]models.SimpleRul ...@@ -480,7 +480,16 @@ func GetUserWorkspaceSimpleRules(workspace, username string) ([]models.SimpleRul
return nil, err 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{ if RulesMatchesRequired(clusterRules, rbacv1.PolicyRule{
Verbs: []string{"*"}, Verbs: []string{"*"},
APIGroups: []string{"*"}, APIGroups: []string{"*"},
...@@ -497,6 +506,7 @@ func GetUserWorkspaceSimpleRules(workspace, username string) ([]models.SimpleRul ...@@ -497,6 +506,7 @@ func GetUserWorkspaceSimpleRules(workspace, username string) ([]models.SimpleRul
} }
return nil, err return nil, err
} }
return GetWorkspaceRoleSimpleRules(workspace, workspaceRole.Annotations[constants.DisplayNameAnnotationKey]), nil return GetWorkspaceRoleSimpleRules(workspace, workspaceRole.Annotations[constants.DisplayNameAnnotationKey]), nil
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册