chore(iam): Remove skipTokenRotationIfRecent feature flag (#112799)
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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
|
||||
|
||||
|
@@ -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"
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user