diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-10-31 20:36:51 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-10-31 20:37:46 +0300 |
commit | 00b8bd761c6de207f27be58df6e3e3c19573b4cc (patch) | |
tree | 617587ca60b7774169e3566e4607807a659dda23 /lib/gitlab/ldap | |
parent | f3279e39e9f5a3fba91a9d920ed4b09e72cdbdee (diff) |
Merge branch 'dm-ldap-identity-normalize-dn' into 'master'
Normalize LDAP DN when looking up identity
Closes #39559
See merge request gitlab-org/gitlab-ce!15103
Diffstat (limited to 'lib/gitlab/ldap')
-rw-r--r-- | lib/gitlab/ldap/auth_hash.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ldap/user.rb | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/gitlab/ldap/auth_hash.rb b/lib/gitlab/ldap/auth_hash.rb index 3123da17fd9..1bd0965679a 100644 --- a/lib/gitlab/ldap/auth_hash.rb +++ b/lib/gitlab/ldap/auth_hash.rb @@ -4,7 +4,7 @@ module Gitlab module LDAP class AuthHash < Gitlab::OAuth::AuthHash def uid - Gitlab::LDAP::Person.normalize_dn(super) + @uid ||= Gitlab::LDAP::Person.normalize_dn(super) end private diff --git a/lib/gitlab/ldap/user.rb b/lib/gitlab/ldap/user.rb index 1793097363e..4d5c67ed892 100644 --- a/lib/gitlab/ldap/user.rb +++ b/lib/gitlab/ldap/user.rb @@ -9,10 +9,11 @@ module Gitlab class User < Gitlab::OAuth::User class << self def find_by_uid_and_provider(uid, provider) - # LDAP distinguished name is case-insensitive + uid = Gitlab::LDAP::Person.normalize_dn(uid) + identity = ::Identity .where(provider: provider) - .iwhere(extern_uid: uid).last + .where(extern_uid: uid).last identity && identity.user end end |