fix: default policy not effective

This commit is contained in:
Qiu Jian
2020-05-22 22:36:33 +08:00
parent 3908877d3b
commit 8d6911a8cb
+3 -4
View File
@@ -22,7 +22,6 @@ import (
"yunion.io/x/log"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/util/netutils"
"yunion.io/x/pkg/utils"
)
type TRbacResult string
@@ -591,7 +590,7 @@ func (policy *SRbacPolicy) IsSystemWidePolicy() bool {
}
func (policy *SRbacPolicy) MatchDomain(domainId string) bool {
if len(domainId) == 0 {
if len(policy.DomainId) == 0 || len(domainId) == 0 {
return true
}
if policy.DomainId == domainId {
@@ -601,7 +600,7 @@ func (policy *SRbacPolicy) MatchDomain(domainId string) bool {
if policy.PublicScope == ScopeSystem {
return true
}
if utils.IsInStringArray(domainId, policy.SharedDomainIds) {
if contains(policy.SharedDomainIds, domainId) {
return true
}
}
@@ -609,7 +608,7 @@ func (policy *SRbacPolicy) MatchDomain(domainId string) bool {
}
func (policy *SRbacPolicy) MatchProject(projectName string) bool {
if len(policy.Projects) == 0 {
if len(policy.Projects) == 0 || len(projectName) == 0 {
return true
}
if contains(policy.Projects, projectName) {