From a87062e4e605c97449bf6765b8ecc106c7a3d46d Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Tue, 31 May 2022 08:19:59 -0400 Subject: [PATCH] AuthProxy: Remove deprecated ldap_sync_ttl setting (#49902) (#49908) * Remove deprecated ldap_sync_ttl (cherry picked from commit 389eec089ec6897167343095fd8910b509c016b1) Co-authored-by: Karl Persson --- conf/defaults.ini | 2 -- pkg/setting/setting.go | 16 +--------------- pkg/setting/setting_test.go | 33 --------------------------------- 3 files changed, 1 insertion(+), 50 deletions(-) diff --git a/conf/defaults.ini b/conf/defaults.ini index 3b4edffb543..d7de0adab5b 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -582,8 +582,6 @@ enabled = false header_name = X-WEBAUTH-USER header_property = username auto_sign_up = true -# Deprecated, use sync_ttl instead -ldap_sync_ttl = 60 sync_ttl = 60 whitelist = headers = diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index 51e1dd77eb9..861fe1358a1 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -49,12 +49,6 @@ const ( ApplicationName = "Grafana" ) -// This constant corresponds to the default value for ldap_sync_ttl in .ini files -// it is used for comparison and has to be kept in sync -const ( - authProxySyncTTL = 60 -) - // zoneInfo names environment variable for setting the path to look for the timezone database in go const zoneInfo = "ZONEINFO" @@ -1332,15 +1326,7 @@ func readAuthSettings(iniFile *ini.File, cfg *Cfg) (err error) { cfg.AuthProxyAutoSignUp = authProxy.Key("auto_sign_up").MustBool(true) cfg.AuthProxyEnableLoginToken = authProxy.Key("enable_login_token").MustBool(false) - ldapSyncVal := authProxy.Key("ldap_sync_ttl").MustInt() - syncVal := authProxy.Key("sync_ttl").MustInt() - - if ldapSyncVal != authProxySyncTTL { - cfg.AuthProxySyncTTL = ldapSyncVal - cfg.Logger.Warn("[Deprecated] the configuration setting 'ldap_sync_ttl' is deprecated, please use 'sync_ttl' instead") - } else { - cfg.AuthProxySyncTTL = syncVal - } + cfg.AuthProxySyncTTL = authProxy.Key("sync_ttl").MustInt() cfg.AuthProxyWhitelist = valueAsString(authProxy, "whitelist", "") diff --git a/pkg/setting/setting_test.go b/pkg/setting/setting_test.go index 1018cd65951..59f8033a5c9 100644 --- a/pkg/setting/setting_test.go +++ b/pkg/setting/setting_test.go @@ -252,39 +252,6 @@ func TestLoadingSettings(t *testing.T) { require.Equal(t, 2, cfg.AuthProxySyncTTL) }) - t.Run("Only ldap_sync_ttl should return the value ldap_sync_ttl", func(t *testing.T) { - cfg := NewCfg() - err := cfg.Load(CommandLineArgs{ - HomePath: "../../", - Args: []string{"cfg:auth.proxy.ldap_sync_ttl=5"}, - }) - require.Nil(t, err) - - require.Equal(t, 5, cfg.AuthProxySyncTTL) - }) - - t.Run("ldap_sync should override ldap_sync_ttl that is default value", func(t *testing.T) { - cfg := NewCfg() - err := cfg.Load(CommandLineArgs{ - HomePath: "../../", - Args: []string{"cfg:auth.proxy.sync_ttl=5"}, - }) - require.Nil(t, err) - - require.Equal(t, 5, cfg.AuthProxySyncTTL) - }) - - t.Run("ldap_sync should not override ldap_sync_ttl that is different from default value", func(t *testing.T) { - cfg := NewCfg() - err := cfg.Load(CommandLineArgs{ - HomePath: "../../", - Args: []string{"cfg:auth.proxy.ldap_sync_ttl=12", "cfg:auth.proxy.sync_ttl=5"}, - }) - require.Nil(t, err) - - require.Equal(t, 12, cfg.AuthProxySyncTTL) - }) - t.Run("Test reading string values from .ini file", func(t *testing.T) { iniFile, err := ini.Load(path.Join(HomePath, "pkg/setting/testdata/invalid.ini")) require.Nil(t, err)