RBAC: FIX Allow specifying several valid scopes for a kind (#93176)

* PermRegistry: Fix regression with actions applying to multiple scopes

* Add tests

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>

---------

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
This commit is contained in:
Gabriel MABILLE
2024-09-10 17:22:40 +01:00
committed by GitHub
co-authored by Ieva
parent 3f9227183d
commit 697afc71b4
2 changed files with 19 additions and 5 deletions
@@ -128,11 +128,9 @@ func (pr *permissionRegistry) RegisterPluginScope(scope string) {
}
func (pr *permissionRegistry) RegisterPermission(action, scope string) error {
if _, ok := pr.actionScopePrefixes[action]; ok {
// action already registered
return nil
if _, ok := pr.actionScopePrefixes[action]; !ok {
pr.actionScopePrefixes[action] = PrefixSet{}
}
pr.actionScopePrefixes[action] = PrefixSet{}
if scope == "" {
// scopeless action