未验证 提交 8b037cef 编写于 作者: H hongming

refine iam policy rules

Signed-off-by: Nhongming <talonwan@yunify.com>
上级 cae0911d
...@@ -45,6 +45,7 @@ const ( ...@@ -45,6 +45,7 @@ const (
ClusterAdmin = "cluster-admin" ClusterAdmin = "cluster-admin"
WorkspaceRegular = "workspace-regular" WorkspaceRegular = "workspace-regular"
WorkspaceViewer = "workspace-viewer" WorkspaceViewer = "workspace-viewer"
WorkspacesManager = "workspaces-manager"
DevopsOwner = "owner" DevopsOwner = "owner"
DevopsReporter = "reporter" DevopsReporter = "reporter"
......
...@@ -564,6 +564,11 @@ func getWorkspaceAdmin(workspaceName string) *rbac.ClusterRole { ...@@ -564,6 +564,11 @@ func getWorkspaceAdmin(workspaceName string) *rbac.ClusterRole {
ResourceNames: []string{workspaceName}, ResourceNames: []string{workspaceName},
Resources: []string{"workspaces", "workspaces/*"}, Resources: []string{"workspaces", "workspaces/*"},
}, },
{
Verbs: []string{"watch"},
APIGroups: []string{""},
Resources: []string{"namespaces"},
},
{ {
Verbs: []string{"list"}, Verbs: []string{"list"},
APIGroups: []string{"iam.kubesphere.io"}, APIGroups: []string{"iam.kubesphere.io"},
...@@ -630,6 +635,11 @@ func getWorkspaceViewer(workspaceName string) *rbac.ClusterRole { ...@@ -630,6 +635,11 @@ func getWorkspaceViewer(workspaceName string) *rbac.ClusterRole {
ResourceNames: []string{workspaceName}, ResourceNames: []string{workspaceName},
Resources: []string{"workspaces", "workspaces/*"}, Resources: []string{"workspaces", "workspaces/*"},
}, },
{
Verbs: []string{"watch"},
APIGroups: []string{""},
Resources: []string{"namespaces"},
},
{ {
Verbs: []string{"get", "list"}, Verbs: []string{"get", "list"},
APIGroups: []string{"openpitrix.io"}, APIGroups: []string{"openpitrix.io"},
......
...@@ -487,7 +487,7 @@ func GetUserWorkspaceSimpleRules(workspace, username string) ([]models.SimpleRul ...@@ -487,7 +487,7 @@ func GetUserWorkspaceSimpleRules(workspace, username string) ([]models.SimpleRul
APIGroups: []string{"*"}, APIGroups: []string{"*"},
Resources: []string{"workspaces", "workspaces/*"}, Resources: []string{"workspaces", "workspaces/*"},
}) { }) {
return GetWorkspaceRoleSimpleRules(workspace, constants.WorkspaceAdmin), nil return GetWorkspaceRoleSimpleRules(workspace, constants.WorkspacesManager), nil
} }
workspaceRole, err := GetUserWorkspaceRole(workspace, username) workspaceRole, err := GetUserWorkspaceRole(workspace, username)
...@@ -534,6 +534,12 @@ func GetWorkspaceRoleSimpleRules(workspace, roleName string) []models.SimpleRule ...@@ -534,6 +534,12 @@ func GetWorkspaceRoleSimpleRules(workspace, roleName string) []models.SimpleRule
{Name: "apps", Actions: []string{"view"}}, {Name: "apps", Actions: []string{"view"}},
{Name: "repos", Actions: []string{"view"}}, {Name: "repos", Actions: []string{"view"}},
} }
case constants.WorkspacesManager:
workspaceRules = []models.SimpleRule{
{Name: "workspaces", Actions: []string{"edit", "delete", "view"}},
{Name: "members", Actions: []string{"edit", "delete", "create", "view"}},
{Name: "roles", Actions: []string{"view"}},
}
} }
return workspaceRules return workspaceRules
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册