fix: string2scope ignore user scope

This commit is contained in:
Qiu Jian
2019-10-11 22:06:05 +08:00
parent 3b991c6c5a
commit 2c7c817ddc
3 changed files with 11 additions and 1 deletions
+4 -1
View File
@@ -289,6 +289,9 @@ func (manager *SPolicyManager) allow(scope rbacutils.TRbacScope, userCred mcclie
key := queryKey(scope, userCred, service, resource, action, extra...)
val := manager.cache.Get(key)
if val != nil {
if consts.IsRbacDebug() {
log.Debugf("query %s:%s:%s:%s from cache %s", service, resource, action, extra, val)
}
return val.(rbacutils.TRbacResult)
}
result := manager.allowWithoutCache(scope, userCred, service, resource, action, extra...)
@@ -410,7 +413,7 @@ func (manager *SPolicyManager) allowWithoutCache(scope rbacutils.TRbacScope, use
}
if consts.IsRbacDebug() {
log.Debugf("[RBAC: %s] %s %s %s %#v permission %s userCred: %s MatchRules: %d(%s) %s", scope, service, resource, action, extra, result, userCred, len(matchRules), jsonutils.Marshal(matchRules), jsonutils.Marshal(policies))
log.Debugf("[RBAC: %s] %s %s %s %#v permission %s userCred: %s MatchRules: %d(%s)", scope, service, resource, action, extra, result, userCred, len(matchRules), jsonutils.Marshal(matchRules))
}
return result
}
+2
View File
@@ -643,6 +643,8 @@ func String2ScopeDefault(str string, defScope TRbacScope) TRbacScope {
return ScopeDomain
case string(ScopeProject):
return ScopeProject
case string(ScopeUser):
return ScopeUser
case "true":
return ScopeSystem
default: