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
Boxiang Sun
gitlab-ce
Commits
9282810f
Commit
9282810f
authored
Jun 08, 2016
by
Patricio Cano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Syntax fixes and better logging around the `ldap_person` method.
parent
c593154c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
lib/gitlab/o_auth/user.rb
lib/gitlab/o_auth/user.rb
+5
-4
spec/lib/gitlab/saml/user_spec.rb
spec/lib/gitlab/saml/user_spec.rb
+1
-2
No files found.
lib/gitlab/o_auth/user.rb
View file @
9282810f
...
@@ -70,15 +70,16 @@ module Gitlab
...
@@ -70,15 +70,16 @@ module Gitlab
# If a corresponding person exists with same uid in a LDAP server,
# If a corresponding person exists with same uid in a LDAP server,
# check if the user already has a GitLab account.
# check if the user already has a GitLab account.
if
(
user
=
Gitlab
::
LDAP
::
User
.
find_by_uid_and_provider
(
ldap_person
.
dn
,
ldap_person
.
provider
))
user
=
Gitlab
::
LDAP
::
User
.
find_by_uid_and_provider
(
ldap_person
.
dn
,
ldap_person
.
provider
)
if
user
# Case when a LDAP user already exists in Gitlab. Add the OAuth identity to existing account.
# Case when a LDAP user already exists in Gitlab. Add the OAuth identity to existing account.
log
.
info
"LDAP account found for user
#{
user
.
username
}
. Building new identity."
log
.
info
"LDAP account found for user
#{
user
.
username
}
. Building new
#{
auth_hash
.
provider
}
identity."
user
.
identities
.
build
(
extern_uid:
auth_hash
.
uid
,
provider:
auth_hash
.
provider
)
user
.
identities
.
build
(
extern_uid:
auth_hash
.
uid
,
provider:
auth_hash
.
provider
)
else
else
log
.
info
'No existing LDAP account was found in GitLab. Checking for OAuth account.'
log
.
info
"No existing LDAP account was found in GitLab. Checking for
#{
auth_hash
.
provider
}
account."
user
=
find_by_uid_and_provider
user
=
find_by_uid_and_provider
if
user
.
nil?
if
user
.
nil?
log
.
info
'No user found with the specified OAuth provider. Creating a new one.'
log
.
info
"No user found using
#{
auth_hash
.
provider
}
provider. Creating a new one."
user
=
build_new_user
user
=
build_new_user
end
end
log
.
info
"Correct account has been found. Adding LDAP identity to user:
#{
user
.
username
}
."
log
.
info
"Correct account has been found. Adding LDAP identity to user:
#{
user
.
username
}
."
...
...
spec/lib/gitlab/saml/user_spec.rb
View file @
9282810f
...
@@ -184,9 +184,9 @@ describe Gitlab::Saml::User, lib: true do
...
@@ -184,9 +184,9 @@ describe Gitlab::Saml::User, lib: true do
create
(
:omniauth_user
,
email:
'john@mail.com'
,
extern_uid:
'uid=user1,ou=People,dc=example'
,
provider:
'saml'
,
username:
'john'
)
create
(
:omniauth_user
,
email:
'john@mail.com'
,
extern_uid:
'uid=user1,ou=People,dc=example'
,
provider:
'saml'
,
username:
'john'
)
local_hash
=
OmniAuth
::
AuthHash
.
new
(
uid:
'uid=user1,ou=People,dc=example'
,
provider:
provider
,
info:
info_hash
)
local_hash
=
OmniAuth
::
AuthHash
.
new
(
uid:
'uid=user1,ou=People,dc=example'
,
provider:
provider
,
info:
info_hash
)
local_saml_user
=
described_class
.
new
(
local_hash
)
local_saml_user
=
described_class
.
new
(
local_hash
)
local_saml_user
.
save
local_saml_user
.
save
local_gl_user
=
local_saml_user
.
gl_user
local_gl_user
=
local_saml_user
.
gl_user
expect
(
local_gl_user
).
to
be_valid
expect
(
local_gl_user
).
to
be_valid
expect
(
local_gl_user
.
identities
.
length
).
to
eql
2
expect
(
local_gl_user
.
identities
.
length
).
to
eql
2
identities_as_hash
=
local_gl_user
.
identities
.
map
{
|
id
|
{
provider:
id
.
provider
,
extern_uid:
id
.
extern_uid
}
}
identities_as_hash
=
local_gl_user
.
identities
.
map
{
|
id
|
{
provider:
id
.
provider
,
extern_uid:
id
.
extern_uid
}
}
...
@@ -194,7 +194,6 @@ describe Gitlab::Saml::User, lib: true do
...
@@ -194,7 +194,6 @@ describe Gitlab::Saml::User, lib: true do
{
provider:
'saml'
,
extern_uid:
'uid=user1,ou=People,dc=example'
}
{
provider:
'saml'
,
extern_uid:
'uid=user1,ou=People,dc=example'
}
])
])
end
end
end
end
end
end
end
end
...
...
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