Преглед на файлове

make hourly cleanup the default behavior

bergquist преди 6 години
родител
ревизия
170783c292
променени са 5 файла, в които са добавени 8 реда и са изтрити 18 реда
  1. 0 3
      conf/defaults.ini
  2. 0 3
      conf/sample.ini
  3. 3 4
      pkg/services/auth/auth_token_test.go
  4. 1 2
      pkg/services/auth/token_cleanup.go
  5. 4 6
      pkg/setting/setting.go

+ 0 - 3
conf/defaults.ini

@@ -256,9 +256,6 @@ login_maximum_lifetime_days = 30
 # How often should auth tokens be rotated for authenticated users when being active. The default is each 10 minutes.
 token_rotation_interval_minutes = 10
 
-# How often should expired auth tokens be deleted from the database. The default is each hour.
-expired_tokens_cleanup_interval_hours = 1
-
 # Set to true to disable (hide) the login form, useful if you use OAuth
 disable_login_form = false
 

+ 0 - 3
conf/sample.ini

@@ -236,9 +236,6 @@ log_queries =
 # How often should auth tokens be rotated for authenticated users when being active. The default is each 10 minutes.
 ;token_rotation_interval_minutes = 10
 
-# How often should expired auth tokens be deleted from the database. The default is each hour.
-;expired_tokens_cleanup_interval_hours = 1
-
 # Set to true to disable (hide) the login form, useful if you use OAuth, defaults to false
 ;disable_login_form = false
 

+ 3 - 4
pkg/services/auth/auth_token_test.go

@@ -423,10 +423,9 @@ func createTestContext(t *testing.T) *testContext {
 	tokenService := &UserAuthTokenService{
 		SQLStore: sqlstore,
 		Cfg: &setting.Cfg{
-			LoginMaxInactiveLifetimeDays:      7,
-			LoginMaxLifetimeDays:              30,
-			TokenRotationIntervalMinutes:      10,
-			ExpiredTokensCleanupIntervalHours: 1,
+			LoginMaxInactiveLifetimeDays: 7,
+			LoginMaxLifetimeDays:         30,
+			TokenRotationIntervalMinutes: 10,
 		},
 		log: log.New("test-logger"),
 	}

+ 1 - 2
pkg/services/auth/token_cleanup.go

@@ -6,8 +6,7 @@ import (
 )
 
 func (srv *UserAuthTokenService) Run(ctx context.Context) error {
-	jobInterval := time.Duration(srv.Cfg.ExpiredTokensCleanupIntervalHours) * time.Hour
-	ticker := time.NewTicker(jobInterval)
+	ticker := time.NewTicker(time.Hour)
 	maxInactiveLifetime := time.Duration(srv.Cfg.LoginMaxInactiveLifetimeDays) * 24 * time.Hour
 	maxLifetime := time.Duration(srv.Cfg.LoginMaxLifetimeDays) * 24 * time.Hour
 

+ 4 - 6
pkg/setting/setting.go

@@ -233,11 +233,10 @@ type Cfg struct {
 	EnterpriseLicensePath            string
 
 	// Auth
-	LoginCookieName                   string
-	LoginMaxInactiveLifetimeDays      int
-	LoginMaxLifetimeDays              int
-	TokenRotationIntervalMinutes      int
-	ExpiredTokensCleanupIntervalHours int
+	LoginCookieName              string
+	LoginMaxInactiveLifetimeDays int
+	LoginMaxLifetimeDays         int
+	TokenRotationIntervalMinutes int
 }
 
 type CommandLineArgs struct {
@@ -673,7 +672,6 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
 	if cfg.TokenRotationIntervalMinutes < 2 {
 		cfg.TokenRotationIntervalMinutes = 2
 	}
-	cfg.ExpiredTokensCleanupIntervalHours = auth.Key("expired_tokens_cleanup_interval_hours").MustInt(1)
 
 	DisableLoginForm = auth.Key("disable_login_form").MustBool(false)
 	DisableSignoutMenu = auth.Key("disable_signout_menu").MustBool(false)