fix: disable policy rule compaction

This commit is contained in:
Qiu Jian
2020-06-16 22:36:00 +08:00
parent 6cedfa30ff
commit 818d40c08b
2 changed files with 2 additions and 28 deletions
-26
View File
@@ -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+)['"]?\)`)
+2 -2
View File
@@ -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
}