Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
1d3889eb
Commit
1d3889eb
authored
Dec 22, 2015
by
Patricio Cano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix identity and user retrieval when special characters are used
parent
1cf45407
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
3 deletions
+19
-3
app/models/identity.rb
app/models/identity.rb
+1
-0
lib/gitlab/ldap/user.rb
lib/gitlab/ldap/user.rb
+2
-2
lib/gitlab/o_auth/user.rb
lib/gitlab/o_auth/user.rb
+1
-1
spec/lib/gitlab/ldap/user_spec.rb
spec/lib/gitlab/ldap/user_spec.rb
+15
-0
No files found.
app/models/identity.rb
View file @
1d3889eb
...
...
@@ -12,6 +12,7 @@
class
Identity
<
ActiveRecord
::
Base
include
Sortable
include
CaseSensitivity
belongs_to
:user
validates
:provider
,
presence:
true
...
...
lib/gitlab/ldap/user.rb
View file @
1d3889eb
...
...
@@ -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
.
mb_chars
.
to_s
).
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
...
...
lib/gitlab/o_auth/user.rb
View file @
1d3889eb
...
...
@@ -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
...
...
spec/lib/gitlab/ldap/user_spec.rb
View file @
1d3889eb
...
...
@@ -42,6 +42,21 @@ describe Gitlab::LDAP::User, lib: true do
end
end
describe
'.find_by_uid_and_provider'
do
it
'retrieves the correct user'
do
special_info
=
{
name:
'John Åström'
,
email:
'john@example.com'
,
nickname:
'jastrom'
}
special_hash
=
OmniAuth
::
AuthHash
.
new
(
uid:
'CN=John Åström,CN=Users,DC=Example,DC=com'
,
provider:
'ldapmain'
,
info:
special_info
)
special_chars_user
=
described_class
.
new
(
special_hash
)
user
=
special_chars_user
.
save
expect
(
described_class
.
find_by_uid_and_provider
(
special_hash
.
uid
,
special_hash
.
provider
)).
to
eq
user
end
end
describe
:find_or_create
do
it
"finds the user if already existing"
do
create
(
:omniauth_user
,
extern_uid:
'my-uid'
,
provider:
'ldapmain'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment