mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-29 03:51:54 +08:00
fix: disable policy rule compaction
This commit is contained in:
@@ -252,32 +252,6 @@ func GetMatchRule(rules []SRbacRule, service string, resource string, action str
|
||||
return matchRule
|
||||
}
|
||||
|
||||
func CompactRules(rules []SRbacRule) []SRbacRule {
|
||||
if len(rules) == 0 {
|
||||
return nil
|
||||
}
|
||||
/*output := make([]SRbacRule, 1)
|
||||
output[0] = rules[0]
|
||||
for i := 1; i < len(rules); i += 1 {
|
||||
isContains := false
|
||||
for j := 0; j < len(output); j += 1 {
|
||||
if output[j].contains(&rules[i]) {
|
||||
isContains = true
|
||||
break
|
||||
}
|
||||
if rules[i].contains(&output[j]) {
|
||||
output[j] = rules[i]
|
||||
isContains = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !isContains {
|
||||
output = append(output, rules[i])
|
||||
}
|
||||
}*/
|
||||
return reduceRules(rules)
|
||||
}
|
||||
|
||||
var (
|
||||
tenantEqualsPattern = regexp.MustCompile(`tenant\s*==\s*['"]?(\w+)['"]?`)
|
||||
roleContainsPattern = regexp.MustCompile(`roles.contains\(['"]?(\w+)['"]?\)`)
|
||||
|
||||
@@ -240,7 +240,7 @@ func rules2Json(rules []SRbacRule) jsonutils.JSONObject {
|
||||
for _, r := range rules {
|
||||
root.AddRule(r)
|
||||
}
|
||||
root.reduce()
|
||||
// root.reduce()
|
||||
return root.json()
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ func json2Rules(json jsonutils.JSONObject) ([]SRbacRule, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "root.parseJson")
|
||||
}
|
||||
root.reduce()
|
||||
// root.reduce()
|
||||
return root.GetRules(), nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user