diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-10-31 10:52:44 +0100 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-10-31 17:13:50 +0100 |
commit | 8399de0c961be75d0cd90e59a7e89fabc11025b8 (patch) | |
tree | d4623bef5ee12e2ea9ca16f99f48c6eaae0a7992 /lib | |
parent | bb63ee682aac171db00bfd2c37395fa1f77a3cae (diff) | |
download | gitlab-ce-8399de0c961be75d0cd90e59a7e89fabc11025b8.tar.gz |
Normalize LDAP DN when looking up identity
Diffstat (limited to 'lib')
-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 |