RBAC: fix wildcard check (#61666)

RBAC: break correct loop
This commit is contained in:
Karl Persson 2023-01-18 13:19:09 +01:00 committed by GitHub
parent 9256ca371d
commit db0be6bc95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -203,16 +203,20 @@ func (f AccessControlDashboardPermissionFilter) Where() (string, []interface{})
func actionsToCheck(actions []string, permissions map[string][]string, wildcards ...accesscontrol.Wildcards) []interface{} { func actionsToCheck(actions []string, permissions map[string][]string, wildcards ...accesscontrol.Wildcards) []interface{} {
toCheck := make([]interface{}, 0, len(actions)) toCheck := make([]interface{}, 0, len(actions))
for _, a := range actions { for _, a := range actions {
var hasWildcard bool var hasWildcard bool
outer:
for _, scope := range permissions[a] { for _, scope := range permissions[a] {
for _, w := range wildcards { for _, w := range wildcards {
if w.Contains(scope) { if w.Contains(scope) {
hasWildcard = true hasWildcard = true
break break outer
} }
} }
} }
if !hasWildcard { if !hasWildcard {
toCheck = append(toCheck, a) toCheck = append(toCheck, a)
} }