[v9.4.x] Auth: Rotate token patch (#62782)

Auth: Rotate token patch (#62676)

* Use singleflight.Group

* Align tests

* Cleanup

(cherry picked from commit 7c1d9769ca)

Co-authored-by: Misi <mgyongyosi@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2023-02-02 18:05:38 +01:00
committed by GitHub
co-authored by Misi
parent 363171b182
commit d31f932800
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())