diff options
author | Robert Speicher <robert@gitlab.com> | 2015-09-23 17:29:25 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2015-09-23 17:29:25 +0000 |
commit | 7bca8745fd9e77d34d544b5ec140160ec3e42a80 (patch) | |
tree | c53f090f712a3200c117b8845c300677a6e1c5a8 | |
parent | 0175769aa88704dac400fb811d8d6433d29b2d16 (diff) | |
parent | 73a3df4de351528dfe954c0f44af1f0e45b221d0 (diff) | |
download | gitlab-ce-7bca8745fd9e77d34d544b5ec140160ec3e42a80.tar.gz |
Merge branch 'fix-ldap-attributes' into 'master'
Fix LDAP attribute mapping
See merge request !1408
-rw-r--r-- | lib/gitlab/ldap/auth_hash.rb | 3 | ||||
-rw-r--r-- | spec/lib/gitlab/ldap/auth_hash_spec.rb | 12 |
2 files changed, 8 insertions, 7 deletions
diff --git a/lib/gitlab/ldap/auth_hash.rb b/lib/gitlab/ldap/auth_hash.rb index 55deeeacd90..bf4dd9542d5 100644 --- a/lib/gitlab/ldap/auth_hash.rb +++ b/lib/gitlab/ldap/auth_hash.rb @@ -6,7 +6,7 @@ module Gitlab private def get_info(key) - attributes = ldap_config.attributes[key] + attributes = ldap_config.attributes[key.to_s] return super unless attributes attributes = Array(attributes) @@ -14,6 +14,7 @@ module Gitlab value = nil attributes.each do |attribute| value = get_raw(attribute) + value = value.first if value break if value.present? end diff --git a/spec/lib/gitlab/ldap/auth_hash_spec.rb b/spec/lib/gitlab/ldap/auth_hash_spec.rb index 18c7924fea1..7d8268536a4 100644 --- a/spec/lib/gitlab/ldap/auth_hash_spec.rb +++ b/spec/lib/gitlab/ldap/auth_hash_spec.rb @@ -24,10 +24,10 @@ describe Gitlab::LDAP::AuthHash do let(:raw_info) do { - uid: '123456', - email: 'johnsmith@example.com', - cn: 'Smith, J.', - fullName: 'John Smith' + uid: ['123456'], + email: ['johnsmith@example.com'], + cn: ['Smith, J.'], + fullName: ['John Smith'] } end @@ -45,8 +45,8 @@ describe Gitlab::LDAP::AuthHash do context "with overridden attributes" do let(:attributes) do { - username: ['mail', 'email'], - name: 'fullName' + 'username' => ['mail', 'email'], + 'name' => 'fullName' } end |