mirror of
https://github.com/grafana/grafana.git
synced 2026-08-14 07:04:57 -05:00
Auth Proxy: replace ini setting ldap_sync_ttl with sync_ttl (#20191)
* Renamed ttl config in code to be more consistent with behaviour * Introduced new setting `sync_ttl` in .ini file * Keeping the old setting `ldap_sync_ttl` in the .ini file as fallback and compatibility.
This commit is contained in:
+12
-2
@@ -147,7 +147,7 @@ var (
|
||||
AuthProxyHeaderName string
|
||||
AuthProxyHeaderProperty string
|
||||
AuthProxyAutoSignUp bool
|
||||
AuthProxyLDAPSyncTtl int
|
||||
AuthProxySyncTtl int
|
||||
AuthProxyWhitelist string
|
||||
AuthProxyHeaders map[string]string
|
||||
|
||||
@@ -854,7 +854,17 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
|
||||
return err
|
||||
}
|
||||
AuthProxyAutoSignUp = authProxy.Key("auto_sign_up").MustBool(true)
|
||||
AuthProxyLDAPSyncTtl = authProxy.Key("ldap_sync_ttl").MustInt()
|
||||
|
||||
ldapSyncVal := authProxy.Key("ldap_sync_ttl").MustInt()
|
||||
syncVal := authProxy.Key("sync_ttl").MustInt()
|
||||
|
||||
if ldapSyncVal != 60 {
|
||||
AuthProxySyncTtl = ldapSyncVal
|
||||
cfg.Logger.Warn("[Deprecated] the configuration setting 'ldap_sync_ttl' is deprecated, please use 'sync_ttl' instead")
|
||||
} else {
|
||||
AuthProxySyncTtl = syncVal
|
||||
}
|
||||
|
||||
AuthProxyWhitelist, err = valueAsString(authProxy, "whitelist", "")
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -227,6 +227,50 @@ func TestLoadingSettings(t *testing.T) {
|
||||
|
||||
So(cfg.RendererCallbackUrl, ShouldEqual, "http://myserver/renderer/")
|
||||
})
|
||||
|
||||
Convey("Only sync_ttl should return the value sync_ttl", func() {
|
||||
cfg := NewCfg()
|
||||
err := cfg.Load(&CommandLineArgs{
|
||||
HomePath: "../../",
|
||||
Args: []string{"cfg:auth.proxy.sync_ttl=2"},
|
||||
})
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
So(AuthProxySyncTtl, ShouldEqual, 2)
|
||||
})
|
||||
|
||||
Convey("Only ldap_sync_ttl should return the value ldap_sync_ttl", func() {
|
||||
cfg := NewCfg()
|
||||
err := cfg.Load(&CommandLineArgs{
|
||||
HomePath: "../../",
|
||||
Args: []string{"cfg:auth.proxy.ldap_sync_ttl=5"},
|
||||
})
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
So(AuthProxySyncTtl, ShouldEqual, 5)
|
||||
})
|
||||
|
||||
Convey("ldap_sync should override ldap_sync_ttl that is default value", func() {
|
||||
cfg := NewCfg()
|
||||
err := cfg.Load(&CommandLineArgs{
|
||||
HomePath: "../../",
|
||||
Args: []string{"cfg:auth.proxy.sync_ttl=5"},
|
||||
})
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
So(AuthProxySyncTtl, ShouldEqual, 5)
|
||||
})
|
||||
|
||||
Convey("ldap_sync should not override ldap_sync_ttl that is different from default value", func() {
|
||||
cfg := NewCfg()
|
||||
err := cfg.Load(&CommandLineArgs{
|
||||
HomePath: "../../",
|
||||
Args: []string{"cfg:auth.proxy.ldap_sync_ttl=12", "cfg:auth.proxy.sync_ttl=5"},
|
||||
})
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
So(AuthProxySyncTtl, ShouldEqual, 12)
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Test reading string values from .ini file", t, func() {
|
||||
|
||||
Reference in New Issue
Block a user