Commit 271272a4 authored by Michael Kozono's avatar Michael Kozono

Merge branch 'dblessing-ldap-username-uid-fix' into 'master'

Include LDAP UID attr in default attrs for LDAP lookups

Closes #212465

See merge request gitlab-org/gitlab!28148
parents 36ee859d 3d66e672
---
title: Include LDAP UID attribute in default attributes for all LDAP lookups
merge_request: 28148
author:
type: fixed
...@@ -178,7 +178,7 @@ module Gitlab ...@@ -178,7 +178,7 @@ module Gitlab
def default_attributes def default_attributes
{ {
'username' => %w(uid sAMAccountName userid), 'username' => %W(#{uid} uid sAMAccountName userid).uniq,
'email' => %w(mail email userPrincipalName), 'email' => %w(mail email userPrincipalName),
'name' => 'cn', 'name' => 'cn',
'first_name' => 'givenName', 'first_name' => 'givenName',
......
...@@ -502,6 +502,20 @@ AtlErSqafbECNDSwS5BX8yDpu5yRBJ4xegO/rNlmb8ICRYkuJapD1xXicFOsmfUK ...@@ -502,6 +502,20 @@ AtlErSqafbECNDSwS5BX8yDpu5yRBJ4xegO/rNlmb8ICRYkuJapD1xXicFOsmfUK
end end
end end
describe '#default_attributes' do
it 'includes the configured uid attribute in the username attributes' do
stub_ldap_config(options: { 'uid' => 'my_uid_attr' })
expect(config.default_attributes['username']).to include('my_uid_attr')
end
it 'only includes unique values for username attributes' do
stub_ldap_config(options: { 'uid' => 'uid' })
expect(config.default_attributes['username']).to contain_exactly('uid', 'sAMAccountName', 'userid')
end
end
describe '#base' do describe '#base' do
context 'when the configured base is not normalized' do context 'when the configured base is not normalized' do
it 'returns the normalized base' do it 'returns the normalized base' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment