From 96bddf90169a0d9c39bdb0ae425ff15dfd03f62b Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Tue, 28 Jun 2016 14:53:44 -0400 Subject: Adding validation for LDAP settings to configuration (#3425) --- model/config.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'model/config.go') diff --git a/model/config.go b/model/config.go index cbb254768..51a3b252e 100644 --- a/model/config.go +++ b/model/config.go @@ -486,6 +486,11 @@ func (o *Config) SetDefaults() { *o.LdapSettings.EmailAttribute = "" } + if o.LdapSettings.UsernameAttribute == nil { + o.LdapSettings.UsernameAttribute = new(string) + *o.LdapSettings.UsernameAttribute = "" + } + if o.LdapSettings.NicknameAttribute == nil { o.LdapSettings.NicknameAttribute = new(string) *o.LdapSettings.NicknameAttribute = "" @@ -709,6 +714,20 @@ func (o *Config) IsValid() *AppError { return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_sync_interval.app_error", nil, "") } + if *o.LdapSettings.Enable { + if *o.LdapSettings.LdapServer == "" || + *o.LdapSettings.BaseDN == "" || + *o.LdapSettings.BindUsername == "" || + *o.LdapSettings.BindPassword == "" || + *o.LdapSettings.FirstNameAttribute == "" || + *o.LdapSettings.LastNameAttribute == "" || + *o.LdapSettings.EmailAttribute == "" || + *o.LdapSettings.UsernameAttribute == "" || + *o.LdapSettings.IdAttribute == "" { + return NewLocAppError("Config.IsValid", "Required LDAP field missing", nil, "") + } + } + return nil } -- cgit v1.2.3-1-g7c22