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
938f2b99
Commit
938f2b99
authored
Jun 16, 2016
by
Drew Blessing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix subsequent SAML sign ins
parent
98cede7e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
lib/gitlab/o_auth/user.rb
lib/gitlab/o_auth/user.rb
+1
-1
spec/lib/gitlab/saml/user_spec.rb
spec/lib/gitlab/saml/user_spec.rb
+17
-1
No files found.
lib/gitlab/o_auth/user.rb
View file @
938f2b99
...
...
@@ -74,7 +74,7 @@ module Gitlab
if
user
# 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
#{
auth_hash
.
provider
}
identity."
user
.
identities
.
build
(
extern_uid:
auth_hash
.
uid
,
provider:
auth_hash
.
provider
)
user
.
identities
.
find_or_initialize_by
(
extern_uid:
auth_hash
.
uid
,
provider:
auth_hash
.
provider
)
else
log
.
info
"No existing LDAP account was found in GitLab. Checking for
#{
auth_hash
.
provider
}
account."
user
=
find_by_uid_and_provider
...
...
spec/lib/gitlab/saml/user_spec.rb
View file @
938f2b99
...
...
@@ -164,7 +164,14 @@ describe Gitlab::Saml::User, lib: true do
end
context
'and LDAP user has an account already'
do
let!
(
:existing_user
)
{
create
(
:omniauth_user
,
email:
'john@mail.com'
,
extern_uid:
'uid=user1,ou=People,dc=example'
,
provider:
'ldapmain'
,
username:
'john'
)
}
before
do
create
(
:omniauth_user
,
email:
'john@mail.com'
,
extern_uid:
'uid=user1,ou=People,dc=example'
,
provider:
'ldapmain'
,
username:
'john'
)
end
it
'adds the omniauth identity to the LDAP account'
do
saml_user
.
save
...
...
@@ -177,6 +184,15 @@ describe Gitlab::Saml::User, lib: true do
{
provider:
'saml'
,
extern_uid:
uid
}
])
end
it
'saves successfully on subsequent tries, when both identities are present'
do
saml_user
.
save
local_saml_user
=
described_class
.
new
(
auth_hash
)
local_saml_user
.
save
expect
(
local_saml_user
.
gl_user
).
to
be_valid
expect
(
local_saml_user
.
gl_user
).
to
be_persisted
end
end
context
'user has SAML user, and wants to add their LDAP identity'
do
...
...
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