summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-09-23 16:37:59 +0200
committerDouwe Maan <douwe@gitlab.com>2015-09-23 16:37:59 +0200
commit73a3df4de351528dfe954c0f44af1f0e45b221d0 (patch)
treea1a22bfcb5613d44227a19edc7b31ab7bdfc22a9
parentcfe663407844f55565e8b7e101f05fc24315e2ff (diff)
downloadgitlab-ce-fix-ldap-attributes.tar.gz
Fix LDAP attribute mappingfix-ldap-attributes
-rw-r--r--lib/gitlab/ldap/auth_hash.rb3
-rw-r--r--spec/lib/gitlab/ldap/auth_hash_spec.rb12
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