From 2efb7fc9e655e727f6751ae37eb55f41a2ab2a35 Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Tue, 16 Jun 2020 23:06:30 +0800 Subject: [PATCH] fix: policy allow if one of the matching rules is allow --- pkg/cloudcommon/policy/policy.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/cloudcommon/policy/policy.go b/pkg/cloudcommon/policy/policy.go index e90b04a445..f2cae2dd30 100644 --- a/pkg/cloudcommon/policy/policy.go +++ b/pkg/cloudcommon/policy/policy.go @@ -403,8 +403,15 @@ func (manager *SPolicyManager) allowWithoutCache(scope rbacutils.TRbacScope, use var result rbacutils.TRbacResult if len(matchRules) > 0 { - rule := rbacutils.GetMatchRule(matchRules, service, resource, action, extra...) - result = rule.Result + result = rbacutils.Deny + for _, rule := range matchRules { + if rule.Result == rbacutils.Allow { + result = rbacutils.Allow + break + } + } + // rule := rbacutils.GetMatchRule(matchRules, service, resource, action, extra...) + // result = rule.Result } else if findMatchPolicy { // if find matched policy, but no rule matching, allow anyway result = rbacutils.Allow