Auth Rules tests & bug fixes

This commit is contained in:
Ben Toogood
2020-05-22 09:31:15 +01:00
parent 1fce0f02b6
commit b2cf501952
2 changed files with 292 additions and 2 deletions

View File

@@ -65,14 +65,14 @@ func Verify(rules []*auth.Rule, acc *auth.Account, res *auth.Resource) error {
// this rule applies to any account
if rule.Scope == "*" && rule.Access == auth.AccessDenied {
return auth.ErrForbidden
} else if rule.Scope == "" && rule.Access == auth.AccessGranted {
} else if rule.Scope == "*" && rule.Access == auth.AccessGranted {
return nil
}
// if the account has the necessary scope
if include(acc.Scopes, rule.Scope) && rule.Access == auth.AccessDenied {
return auth.ErrForbidden
} else if rule.Scope == "" && rule.Access == auth.AccessGranted {
} else if include(acc.Scopes, rule.Scope) && rule.Access == auth.AccessGranted {
return nil
}
}