Access control: Fix searching permissions from cache (#87489)
* Fix searching permissions from cache * Write permissions to cache
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user