mirror of
https://github.com/grafana/grafana.git
synced 2025-01-02 12:17:01 -06:00
Fix default maximum lifetime an authenticated user can be logged in (#30030)
This commit is contained in:
parent
08fbe345a9
commit
fd1b2904cd
@ -1045,7 +1045,7 @@ func readAuthSettings(iniFile *ini.File, cfg *Cfg) (err error) {
|
||||
maxLifetimeDaysVal = fmt.Sprintf("%sd", maxLifetimeDaysVal)
|
||||
cfg.Logger.Warn("[Deprecated] the configuration setting 'login_maximum_lifetime_days' is deprecated, please use 'login_maximum_lifetime_duration' instead")
|
||||
} else {
|
||||
maxLifetimeDaysVal = "7d"
|
||||
maxLifetimeDaysVal = "30d"
|
||||
}
|
||||
maxLifetimeDurationVal := valueAsString(auth, "login_maximum_lifetime_duration", maxLifetimeDaysVal)
|
||||
cfg.LoginMaxLifetime, err = gtime.ParseDuration(maxLifetimeDurationVal)
|
||||
|
@ -375,4 +375,17 @@ func TestAuthDurationSettings(t *testing.T) {
|
||||
err = readAuthSettings(f, cfg)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, maxLifetimeDurationTest, cfg.LoginMaxLifetime)
|
||||
|
||||
f = ini.Empty()
|
||||
sec, err = f.NewSection("auth")
|
||||
require.NoError(t, err)
|
||||
_, err = sec.NewKey("login_maximum_lifetime_days", "")
|
||||
require.NoError(t, err)
|
||||
_, err = sec.NewKey("login_maximum_lifetime_duration", "")
|
||||
require.NoError(t, err)
|
||||
maxLifetimeDurationTest, err = time.ParseDuration("720h")
|
||||
require.NoError(t, err)
|
||||
err = readAuthSettings(f, cfg)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, maxLifetimeDurationTest, cfg.LoginMaxLifetime)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user