Files
grafana/pkg/services/accesscontrol/cacheutils.go
T
Alexander Zobnin d1c582815a Access control: Fix searching permissions from cache (#87489)
* Fix searching permissions from cache

* Write permissions to cache
2024-05-08 16:08:21 +02:00

27 lines
748 B
Go

package accesscontrol
import (
"fmt"
"strings"
"github.com/grafana/grafana/pkg/services/auth/identity"
)
func GetPermissionCacheKey(user identity.Requester) string {
return fmt.Sprintf("rbac-permissions-%s", user.GetCacheKey())
}
func GetUserDirectPermissionCacheKey(user identity.Requester) string {
return fmt.Sprintf("rbac-permissions-direct-%s", user.GetCacheKey())
}
func GetBasicRolePermissionCacheKey(role string, orgID int64) string {
roleKey := strings.Replace(role, " ", "_", -1)
roleKey = strings.ToLower(roleKey)
return fmt.Sprintf("rbac-permissions-basic-role-%d-%s", orgID, roleKey)
}
func GetTeamPermissionCacheKey(teamID int64, orgID int64) string {
return fmt.Sprintf("rbac-permissions-team-%d-%d", orgID, teamID)
}