Fix LDAP attribute mapping
This commit is contained in:
parent
cfe6634078
commit
73a3df4de3
|
@ -6,7 +6,7 @@ module Gitlab
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_info(key)
|
def get_info(key)
|
||||||
attributes = ldap_config.attributes[key]
|
attributes = ldap_config.attributes[key.to_s]
|
||||||
return super unless attributes
|
return super unless attributes
|
||||||
|
|
||||||
attributes = Array(attributes)
|
attributes = Array(attributes)
|
||||||
|
@ -14,6 +14,7 @@ module Gitlab
|
||||||
value = nil
|
value = nil
|
||||||
attributes.each do |attribute|
|
attributes.each do |attribute|
|
||||||
value = get_raw(attribute)
|
value = get_raw(attribute)
|
||||||
|
value = value.first if value
|
||||||
break if value.present?
|
break if value.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,10 @@ describe Gitlab::LDAP::AuthHash do
|
||||||
|
|
||||||
let(:raw_info) do
|
let(:raw_info) do
|
||||||
{
|
{
|
||||||
uid: '123456',
|
uid: ['123456'],
|
||||||
email: 'johnsmith@example.com',
|
email: ['johnsmith@example.com'],
|
||||||
cn: 'Smith, J.',
|
cn: ['Smith, J.'],
|
||||||
fullName: 'John Smith'
|
fullName: ['John Smith']
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ describe Gitlab::LDAP::AuthHash do
|
||||||
context "with overridden attributes" do
|
context "with overridden attributes" do
|
||||||
let(:attributes) do
|
let(:attributes) do
|
||||||
{
|
{
|
||||||
username: ['mail', 'email'],
|
'username' => ['mail', 'email'],
|
||||||
name: 'fullName'
|
'name' => 'fullName'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue