RBAC: Optimize permissions caching (#92412)

* Access control: Use composite cache key for team permissions

* use composite key for teams

* use cache for hotpath (getCachedUserPermissions)

* fix linter

* fix sorting

---------

Co-authored-by: Jeff Levin <jeff@levinology.com>
This commit is contained in:
Alexander Zobnin
2024-08-27 10:31:52 +02:00
committed by GitHub
co-authored by Jeff Levin
parent a54ec2341c
commit 488e994d37
3 changed files with 29 additions and 3 deletions
@@ -6,6 +6,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/grafana/authlib/claims"
"github.com/grafana/grafana/pkg/services/org"
"github.com/grafana/grafana/pkg/services/user"
)
@@ -68,7 +69,7 @@ func TestPermissionCacheKey(t *testing.T) {
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, tc.expected, GetPermissionCacheKey(tc.signedInUser))
assert.Equal(t, tc.expected, GetUserPermissionCacheKey(tc.signedInUser))
})
}
}