From f34a820a223c9ec7bfac5996b6245d364d25fe1a Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Thu, 9 Jun 2016 12:08:02 -0400 Subject: Correctly set defaults for all LDAPSettings in the config (#3301) --- model/config.go | 88 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 24 deletions(-) (limited to 'model/config.go') diff --git a/model/config.go b/model/config.go index e63dca073..55606ee8d 100644 --- a/model/config.go +++ b/model/config.go @@ -429,19 +429,39 @@ func (o *Config) SetDefaults() { *o.SupportSettings.SupportEmail = "feedback@mattermost.com" } + if o.LdapSettings.Enable == nil { + o.LdapSettings.Enable = new(bool) + *o.LdapSettings.Enable = false + } + + if o.LdapSettings.LdapServer == nil { + o.LdapSettings.LdapServer = new(string) + *o.LdapSettings.LdapServer = "" + } + if o.LdapSettings.LdapPort == nil { o.LdapSettings.LdapPort = new(int) *o.LdapSettings.LdapPort = 389 } - if o.LdapSettings.QueryTimeout == nil { - o.LdapSettings.QueryTimeout = new(int) - *o.LdapSettings.QueryTimeout = 60 + if o.LdapSettings.ConnectionSecurity == nil { + o.LdapSettings.ConnectionSecurity = new(string) + *o.LdapSettings.ConnectionSecurity = "" } - if o.LdapSettings.Enable == nil { - o.LdapSettings.Enable = new(bool) - *o.LdapSettings.Enable = false + if o.LdapSettings.BaseDN == nil { + o.LdapSettings.BaseDN = new(string) + *o.LdapSettings.BaseDN = "" + } + + if o.LdapSettings.BindUsername == nil { + o.LdapSettings.BindUsername = new(string) + *o.LdapSettings.BindUsername = "" + } + + if o.LdapSettings.BindPassword == nil { + o.LdapSettings.BindPassword = new(string) + *o.LdapSettings.BindPassword = "" } if o.LdapSettings.UserFilter == nil { @@ -449,9 +469,29 @@ func (o *Config) SetDefaults() { *o.LdapSettings.UserFilter = "" } - if o.LdapSettings.LoginFieldName == nil { - o.LdapSettings.LoginFieldName = new(string) - *o.LdapSettings.LoginFieldName = "" + if o.LdapSettings.FirstNameAttribute == nil { + o.LdapSettings.FirstNameAttribute = new(string) + *o.LdapSettings.FirstNameAttribute = "" + } + + if o.LdapSettings.LastNameAttribute == nil { + o.LdapSettings.LastNameAttribute = new(string) + *o.LdapSettings.LastNameAttribute = "" + } + + if o.LdapSettings.EmailAttribute == nil { + o.LdapSettings.EmailAttribute = new(string) + *o.LdapSettings.EmailAttribute = "" + } + + if o.LdapSettings.NicknameAttribute == nil { + o.LdapSettings.NicknameAttribute = new(string) + *o.LdapSettings.NicknameAttribute = "" + } + + if o.LdapSettings.IdAttribute == nil { + o.LdapSettings.IdAttribute = new(string) + *o.LdapSettings.IdAttribute = "" } if o.LdapSettings.SyncIntervalMinutes == nil { @@ -459,6 +499,21 @@ func (o *Config) SetDefaults() { *o.LdapSettings.SyncIntervalMinutes = 60 } + if o.LdapSettings.SkipCertificateVerification == nil { + o.LdapSettings.SkipCertificateVerification = new(bool) + *o.LdapSettings.SkipCertificateVerification = false + } + + if o.LdapSettings.QueryTimeout == nil { + o.LdapSettings.QueryTimeout = new(int) + *o.LdapSettings.QueryTimeout = 60 + } + + if o.LdapSettings.LoginFieldName == nil { + o.LdapSettings.LoginFieldName = new(string) + *o.LdapSettings.LoginFieldName = "" + } + if o.ServiceSettings.SessionLengthWebInDays == nil { o.ServiceSettings.SessionLengthWebInDays = new(int) *o.ServiceSettings.SessionLengthWebInDays = 30 @@ -524,21 +579,6 @@ func (o *Config) SetDefaults() { *o.ComplianceSettings.EnableDaily = false } - if o.LdapSettings.ConnectionSecurity == nil { - o.LdapSettings.ConnectionSecurity = new(string) - *o.LdapSettings.ConnectionSecurity = "" - } - - if o.LdapSettings.SkipCertificateVerification == nil { - o.LdapSettings.SkipCertificateVerification = new(bool) - *o.LdapSettings.SkipCertificateVerification = false - } - - if o.LdapSettings.NicknameAttribute == nil { - o.LdapSettings.NicknameAttribute = new(string) - *o.LdapSettings.NicknameAttribute = "" - } - if o.LocalizationSettings.DefaultServerLocale == nil { o.LocalizationSettings.DefaultServerLocale = new(string) *o.LocalizationSettings.DefaultServerLocale = DEFAULT_LOCALE -- cgit v1.2.3-1-g7c22