AuthN: Add in-memory cache for oauth token refresh hook (#63569)

* OAuthSyncHook: Add in-memory cache so we don't have to perform the check on every request

Co-authored-by: Jo <joao.guerreiro@grafana.com>
This commit is contained in:
Karl Persson
2023-02-23 09:36:21 +01:00
committed by GitHub
parent f94b957333
commit 057d9c45fa
3 changed files with 38 additions and 8 deletions

View File

@@ -8,6 +8,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/grafana/grafana/pkg/infra/localcache"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/services/auth"
"github.com/grafana/grafana/pkg/services/auth/authtest"
@@ -17,7 +18,7 @@ import (
"github.com/grafana/grafana/pkg/services/user"
)
func TestOauthTokenSync_SyncOauthTokenHook(t *testing.T) {
func TestOauthTokenSync_SyncOAuthTokenHook(t *testing.T) {
type testCase struct {
desc string
identity *authn.Identity
@@ -117,8 +118,9 @@ func TestOauthTokenSync_SyncOauthTokenHook(t *testing.T) {
},
}
sync := &OauthTokenSync{
sync := &OAuthTokenSync{
log: log.NewNopLogger(),
cache: localcache.New(0, 0),
service: service,
sessionService: sessionService,
}