diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-12-24 16:35:00 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-12-24 16:35:00 +0000 |
commit | 835333c42609e85ca002816976522b4096863bf7 (patch) | |
tree | a581fb9da6580c8ebd5d00b04e282e532e81b78d /lib | |
parent | e1a47bd1232a1463b8d5d95b8fd624bb969f7de7 (diff) | |
parent | 662aa8ec35a2c1a898ade5be3a525591786cd9f5 (diff) | |
download | gitlab-ce-835333c42609e85ca002816976522b4096863bf7.tar.gz |
Merge branch 'ldap-special-chars-fix' into 'master'
Fix identity and user retrieval when special characters are used
Fixes #4023
I also added tests to make sure the user with special characters in his name is returned correctly.
@rspeicher this probably should be added to 8.3 as a patch.
See merge request !2176
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ldap/user.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/o_auth/user.rb | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/gitlab/ldap/user.rb b/lib/gitlab/ldap/user.rb index 4be99dd88c2..aef08c97d1d 100644 --- a/lib/gitlab/ldap/user.rb +++ b/lib/gitlab/ldap/user.rb @@ -14,7 +14,7 @@ module Gitlab # LDAP distinguished name is case-insensitive identity = ::Identity. where(provider: provider). - where('lower(extern_uid) = ?', uid.mb_chars.downcase.to_s).last + iwhere(extern_uid: uid).last identity && identity.user end end @@ -31,7 +31,7 @@ module Gitlab def find_by_uid_and_provider self.class.find_by_uid_and_provider( - auth_hash.uid.downcase, auth_hash.provider) + auth_hash.uid, auth_hash.provider) end def find_by_email @@ -47,7 +47,7 @@ module Gitlab # find_or_initialize_by doesn't update `gl_user.identities`, and isn't autosaved. identity = gl_user.identities.find { |identity| identity.provider == auth_hash.provider } identity ||= gl_user.identities.build(provider: auth_hash.provider) - + # For a new user set extern_uid to the LDAP DN # For an existing user with matching email but changed DN, update the DN. # For an existing user with no change in DN, this line changes nothing. diff --git a/lib/gitlab/o_auth/user.rb b/lib/gitlab/o_auth/user.rb index 17ce4d4b174..f1a362f5303 100644 --- a/lib/gitlab/o_auth/user.rb +++ b/lib/gitlab/o_auth/user.rb @@ -64,7 +64,7 @@ module Gitlab # If a corresponding person exists with same uid in a LDAP server, # set up a Gitlab user with dual LDAP and Omniauth identities. - if user = Gitlab::LDAP::User.find_by_uid_and_provider(ldap_person.dn.downcase, ldap_person.provider) + if user = Gitlab::LDAP::User.find_by_uid_and_provider(ldap_person.dn, ldap_person.provider) # Case when a LDAP user already exists in Gitlab. Add the Omniauth identity to existing account. user.identities.build(extern_uid: auth_hash.uid, provider: auth_hash.provider) else |