fix: workspace manage permission
Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
@@ -481,10 +481,13 @@ func GetUserWorkspaceSimpleRules(workspace, username string) ([]models.SimpleRul
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if workspacesManager, err := policy.GetClusterAction("workspaces", "edit"); err == nil {
|
// workspace manager
|
||||||
if rulesMatchesAction(clusterRules, workspacesManager) {
|
if RulesMatchesRequired(clusterRules, rbacv1.PolicyRule{
|
||||||
return GetWorkspaceRoleSimpleRules(workspace, constants.WorkspaceAdmin), nil
|
Verbs: []string{"*"},
|
||||||
}
|
APIGroups: []string{"*"},
|
||||||
|
Resources: []string{"workspaces", "workspaces/*"},
|
||||||
|
}) {
|
||||||
|
return GetWorkspaceRoleSimpleRules(workspace, constants.WorkspaceAdmin), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
workspaceRole, err := GetUserWorkspaceRole(workspace, username)
|
workspaceRole, err := GetUserWorkspaceRole(workspace, username)
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package policy
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
"kubesphere.io/kubesphere/pkg/models"
|
"kubesphere.io/kubesphere/pkg/models"
|
||||||
@@ -60,7 +59,7 @@ var (
|
|||||||
{Name: "workspaces",
|
{Name: "workspaces",
|
||||||
Actions: []models.Action{
|
Actions: []models.Action{
|
||||||
{
|
{
|
||||||
Name: "manager",
|
Name: "manage",
|
||||||
Rules: []v1.PolicyRule{
|
Rules: []v1.PolicyRule{
|
||||||
{
|
{
|
||||||
Verbs: []string{"*"},
|
Verbs: []string{"*"},
|
||||||
@@ -1084,16 +1083,3 @@ var (
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetClusterAction(module, action string) (models.Action, error) {
|
|
||||||
for _, rule := range ClusterRoleRuleMapping {
|
|
||||||
if rule.Name == module {
|
|
||||||
for _, act := range rule.Actions {
|
|
||||||
if act.Name == action {
|
|
||||||
return act, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return models.Action{}, fmt.Errorf("not found")
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user