Auth: Rotate token patch (#62676)

* Use singleflight.Group

* Align tests

* Cleanup
This commit is contained in:
Misi
2023-02-02 14:36:16 +01:00
committed by GitHub
parent 3c01ae2c9e
commit 7c1d9769ca
9 changed files with 122 additions and 88 deletions
+4 -3
View File
@@ -13,10 +13,11 @@ import (
"testing"
"time"
"github.com/grafana/grafana-plugin-sdk-go/backend/gtime"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana-plugin-sdk-go/backend/gtime"
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/infra/db/dbtest"
"github.com/grafana/grafana/pkg/infra/fs"
@@ -344,9 +345,9 @@ func TestMiddlewareContext(t *testing.T) {
}
sc.userAuthTokenService.TryRotateTokenProvider = func(ctx context.Context, userToken *auth.UserToken,
clientIP net.IP, userAgent string) (bool, error) {
clientIP net.IP, userAgent string) (bool, *auth.UserToken, error) {
userToken.UnhashedToken = "rotated"
return true, nil
return true, userToken, nil
}
maxAge := int(sc.cfg.LoginMaxLifetime.Seconds())