AuthProxy: Remove deprecated ldap_sync_ttl setting (#49902)

* Remove deprecated ldap_sync_ttl
This commit is contained in:
Karl Persson
2022-05-31 14:08:24 +02:00
committed by GitHub
parent 0089779945
commit 389eec089e
3 changed files with 1 additions and 50 deletions
-2
View File
@@ -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 =
+1 -15
View File
@@ -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", "")
-33
View File
@@ -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)