diff options
author | Robert Speicher <robert@gitlab.com> | 2017-08-23 21:42:29 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-08-23 21:42:29 +0000 |
commit | cdf87fe890a589da2c73e2f758e98f1c014d7953 (patch) | |
tree | c6f7d5c2fd9b9ba3e590589248d92bf037959a56 /lib | |
parent | 49b9968dc0d3927942cf2db54fa296bfbdac1f73 (diff) | |
parent | c1cf5f41018dd4cf0523c6a80c8617651d88658c (diff) | |
download | gitlab-ce-cdf87fe890a589da2c73e2f758e98f1c014d7953.tar.gz |
Merge branch 'dm-ldap-adapter-attributes' into 'master'
Support simple string LDAP attribute specifications, and search for name rather…
Closes #36841
See merge request !13776
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ldap/adapter.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/ldap/person.rb | 9 |
2 files changed, 10 insertions, 5 deletions
diff --git a/lib/gitlab/ldap/adapter.rb b/lib/gitlab/ldap/adapter.rb index 8867a91c244..cd7e4ca7b7e 100644 --- a/lib/gitlab/ldap/adapter.rb +++ b/lib/gitlab/ldap/adapter.rb @@ -73,7 +73,7 @@ module Gitlab private def user_options(field, value, limit) - options = { attributes: user_attributes } + options = { attributes: Gitlab::LDAP::Person.ldap_attributes(config).compact.uniq } options[:size] = limit if limit if field.to_sym == :dn @@ -99,10 +99,6 @@ module Gitlab filter end end - - def user_attributes - %W(#{config.uid} cn dn) + config.attributes['username'] + config.attributes['email'] - end end end end diff --git a/lib/gitlab/ldap/person.rb b/lib/gitlab/ldap/person.rb index e138b466a34..4d6f8ac79de 100644 --- a/lib/gitlab/ldap/person.rb +++ b/lib/gitlab/ldap/person.rb @@ -21,6 +21,15 @@ module Gitlab adapter.dn_matches_filter?(dn, AD_USER_DISABLED) end + def self.ldap_attributes(config) + [ + 'dn', # Used in `dn` + config.uid, # Used in `uid` + *config.attributes['name'], # Used in `name` + *config.attributes['email'] # Used in `email` + ] + end + def initialize(entry, provider) Rails.logger.debug { "Instantiating #{self.class.name} with LDIF:\n#{entry.to_ldif}" } @entry = entry |