diff --git a/packages/grafana-data/src/types/featureToggles.gen.ts b/packages/grafana-data/src/types/featureToggles.gen.ts index 3b2f3214f04..c070fc97022 100644 --- a/packages/grafana-data/src/types/featureToggles.gen.ts +++ b/packages/grafana-data/src/types/featureToggles.gen.ts @@ -1051,11 +1051,6 @@ export interface FeatureToggles { */ restoreDashboards?: boolean; /** - * Skip token rotation if it was already rotated less than 5 seconds ago - * @default true - */ - skipTokenRotationIfRecent?: boolean; - /** * Enable configuration of alert enrichments in Grafana Cloud. * @default false */ diff --git a/pkg/services/auth/authimpl/auth_token.go b/pkg/services/auth/authimpl/auth_token.go index e8a00ff8c85..1cb2b8989d4 100644 --- a/pkg/services/auth/authimpl/auth_token.go +++ b/pkg/services/auth/authimpl/auth_token.go @@ -303,7 +303,7 @@ func (s *UserAuthTokenService) RotateToken(ctx context.Context, cmd auth.RotateC log := s.log.FromContext(ctx).New("tokenID", token.Id, "userID", token.UserId, "createdAt", token.CreatedAt, "rotatedAt", token.RotatedAt) // Avoid multiple instances in HA mode rotating at the same time. - if s.features.IsEnabled(ctx, featuremgmt.FlagSkipTokenRotationIfRecent) && time.Unix(token.RotatedAt, 0).Add(SkipRotationTime).After(getTime()) { + if time.Unix(token.RotatedAt, 0).Add(SkipRotationTime).After(getTime()) { log.Debug("Token was last rotated very recently, skipping rotation") span.SetAttributes(attribute.Bool("skipped", true)) return token, nil @@ -327,16 +327,13 @@ func (s *UserAuthTokenService) RotateToken(ctx context.Context, cmd auth.RotateC } res, err, _ := s.singleflight.Do(cmd.UnHashedToken, func() (any, error) { - if s.features.IsEnabled(ctx, featuremgmt.FlagSkipTokenRotationIfRecent) { - var token *auth.UserToken - err := s.sqlStore.InTransaction(ctx, func(ctx context.Context) error { - var err error - token, err = rotate(ctx) - return err - }) - return token, err - } - return rotate(ctx) + var token *auth.UserToken + err := s.sqlStore.InTransaction(ctx, func(ctx context.Context) error { + var err error + token, err = rotate(ctx) + return err + }) + return token, err }) if err != nil { @@ -375,11 +372,7 @@ func (s *UserAuthTokenService) rotateToken(ctx context.Context, token *auth.User now := getTime() var affected int64 - withDbSession := s.sqlStore.WithDbSession - if !s.features.IsEnabled(ctx, featuremgmt.FlagSkipTokenRotationIfRecent) { - withDbSession = s.sqlStore.WithTransactionalDbSession - } - err = withDbSession(ctx, func(dbSession *db.Session) error { + err = s.sqlStore.WithDbSession(ctx, func(dbSession *db.Session) error { res, err := dbSession.Exec(sql, userAgent, clientIPStr, hashedToken, s.sqlStore.GetDialect().BooleanValue(false), now.Unix(), token.Id) if err != nil { return err diff --git a/pkg/services/auth/authimpl/auth_token_test.go b/pkg/services/auth/authimpl/auth_token_test.go index 4ecef2cc17f..ffd12822d4c 100644 --- a/pkg/services/auth/authimpl/auth_token_test.go +++ b/pkg/services/auth/authimpl/auth_token_test.go @@ -20,7 +20,6 @@ import ( "github.com/grafana/grafana/pkg/infra/tracing" "github.com/grafana/grafana/pkg/services/auth" "github.com/grafana/grafana/pkg/services/auth/authtest" - "github.com/grafana/grafana/pkg/services/featuremgmt" "github.com/grafana/grafana/pkg/services/quota" "github.com/grafana/grafana/pkg/services/secrets/fakes" "github.com/grafana/grafana/pkg/services/user" @@ -721,7 +720,6 @@ func createTestContext(t *testing.T) *testContext { log: log.New("test-logger"), singleflight: new(singleflight.Group), externalSessionStore: extSessionStore, - features: featuremgmt.WithFeatures(featuremgmt.FlagSkipTokenRotationIfRecent), tracer: tracer, } diff --git a/pkg/services/featuremgmt/registry.go b/pkg/services/featuremgmt/registry.go index 34e66bc254f..2aca483c185 100644 --- a/pkg/services/featuremgmt/registry.go +++ b/pkg/services/featuremgmt/registry.go @@ -1819,15 +1819,6 @@ var ( HideFromAdminPage: true, Expression: "false", }, - { - Name: "skipTokenRotationIfRecent", - Description: "Skip token rotation if it was already rotated less than 5 seconds ago", - Stage: FeatureStageGeneralAvailability, - Owner: identityAccessTeam, - HideFromAdminPage: true, - HideFromDocs: true, - Expression: "true", // enabled by default - }, { Name: "alertEnrichment", Description: "Enable configuration of alert enrichments in Grafana Cloud.", diff --git a/pkg/services/featuremgmt/toggles_gen.csv b/pkg/services/featuremgmt/toggles_gen.csv index b232bbee6e7..8481c677d09 100644 --- a/pkg/services/featuremgmt/toggles_gen.csv +++ b/pkg/services/featuremgmt/toggles_gen.csv @@ -236,7 +236,6 @@ kubernetesAuthzResourcePermissionApis,experimental,@grafana/identity-access-team kubernetesAuthzZanzanaSync,experimental,@grafana/identity-access-team,false,false,false kubernetesAuthnMutation,experimental,@grafana/identity-access-team,false,false,false restoreDashboards,experimental,@grafana/grafana-frontend-platform,false,false,false -skipTokenRotationIfRecent,GA,@grafana/identity-access-team,false,false,false alertEnrichment,experimental,@grafana/alerting-squad,false,false,false alertEnrichmentMultiStep,experimental,@grafana/alerting-squad,false,false,false alertEnrichmentConditional,experimental,@grafana/alerting-squad,false,false,false diff --git a/pkg/services/featuremgmt/toggles_gen.go b/pkg/services/featuremgmt/toggles_gen.go index 452f3fab788..dc216663bd4 100644 --- a/pkg/services/featuremgmt/toggles_gen.go +++ b/pkg/services/featuremgmt/toggles_gen.go @@ -954,10 +954,6 @@ const ( // Enables restore deleted dashboards feature FlagRestoreDashboards = "restoreDashboards" - // FlagSkipTokenRotationIfRecent - // Skip token rotation if it was already rotated less than 5 seconds ago - FlagSkipTokenRotationIfRecent = "skipTokenRotationIfRecent" - // FlagAlertEnrichment // Enable configuration of alert enrichments in Grafana Cloud. FlagAlertEnrichment = "alertEnrichment" diff --git a/pkg/services/featuremgmt/toggles_gen.json b/pkg/services/featuremgmt/toggles_gen.json index 9d56cde1e30..59a7491cb12 100644 --- a/pkg/services/featuremgmt/toggles_gen.json +++ b/pkg/services/featuremgmt/toggles_gen.json @@ -3601,7 +3601,8 @@ "metadata": { "name": "skipTokenRotationIfRecent", "resourceVersion": "1753448760331", - "creationTimestamp": "2025-06-03T06:59:40Z" + "creationTimestamp": "2025-06-03T06:59:40Z", + "deletionTimestamp": "2025-10-22T10:29:12Z" }, "spec": { "description": "Skip token rotation if it was already rotated less than 5 seconds ago",