summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-07-12 16:13:18 +0000
committerDouwe Maan <douwe@gitlab.com>2017-07-12 16:13:18 +0000
commitbc1bb50685fc5d7dd588079304719307edbb4c05 (patch)
treeb772d0d75395254658ebd54cc79792c0a8f022c0
parent92949e05b9d4c19bb6fd4d8fff58380db6bb0662 (diff)
parent7f350ba16d85efff992a9fe6bd6ad734244656d9 (diff)
downloadgitlab-ce-bc1bb50685fc5d7dd588079304719307edbb4c05.tar.gz
Merge branch 'backport-ee-2405' into 'master'
Backport "Automatically link Kerberos users and LDAP people" changes to CE See merge request !12807
-rw-r--r--lib/gitlab/o_auth/user.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/gitlab/o_auth/user.rb b/lib/gitlab/o_auth/user.rb
index b3f453e506d..3f2bbd9f6a6 100644
--- a/lib/gitlab/o_auth/user.rb
+++ b/lib/gitlab/o_auth/user.rb
@@ -101,14 +101,18 @@ module Gitlab
# Look for a corresponding person with same uid in any of the configured LDAP providers
Gitlab::LDAP::Config.providers.each do |provider|
adapter = Gitlab::LDAP::Adapter.new(provider)
- @ldap_person = Gitlab::LDAP::Person.find_by_uid(auth_hash.uid, adapter)
- # The `uid` might actually be a DN. Try it next.
- @ldap_person ||= Gitlab::LDAP::Person.find_by_dn(auth_hash.uid, adapter)
+ @ldap_person = find_ldap_person(auth_hash, adapter)
break if @ldap_person
end
@ldap_person
end
+ def find_ldap_person(auth_hash, adapter)
+ by_uid = Gitlab::LDAP::Person.find_by_uid(auth_hash.uid, adapter)
+ # The `uid` might actually be a DN. Try it next.
+ by_uid || Gitlab::LDAP::Person.find_by_dn(auth_hash.uid, adapter)
+ end
+
def ldap_config
Gitlab::LDAP::Config.new(ldap_person.provider) if ldap_person
end