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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
4d2f3611
Commit
4d2f3611
authored
Jul 21, 2015
by
Joel Koglin
Committed by
Joel Koglin
Aug 21, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #993: Fixed login failure when extern_uid changes
parent
f5b3bf84
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
5 deletions
+46
-5
CHANGELOG
CHANGELOG
+1
-0
app/models/user.rb
app/models/user.rb
+1
-1
db/migrate/20150817163600_deduplicate_user_identities.rb
db/migrate/20150817163600_deduplicate_user_identities.rb
+14
-0
db/schema.rb
db/schema.rb
+1
-1
lib/gitlab/ldap/user.rb
lib/gitlab/ldap/user.rb
+7
-3
spec/lib/gitlab/ldap/user_spec.rb
spec/lib/gitlab/ldap/user_spec.rb
+22
-0
No files found.
CHANGELOG
View file @
4d2f3611
...
@@ -75,6 +75,7 @@ v 7.14.0 (unreleased)
...
@@ -75,6 +75,7 @@ v 7.14.0 (unreleased)
- Update Flowdock integration to support new Flowdock API (Boyan Tabakov)
- Update Flowdock integration to support new Flowdock API (Boyan Tabakov)
- Remove author from files view (Sven Strickroth)
- Remove author from files view (Sven Strickroth)
- Fix infinite loop when SAML was incorrectly configured.
- Fix infinite loop when SAML was incorrectly configured.
- Fixed login failure when extern_uid changes (Joel Koglin)
v 7.13.5
v 7.13.5
- Satellites reverted
- Satellites reverted
...
...
app/models/user.rb
View file @
4d2f3611
...
@@ -104,7 +104,7 @@ class User < ActiveRecord::Base
...
@@ -104,7 +104,7 @@ class User < ActiveRecord::Base
# Profile
# Profile
has_many
:keys
,
dependent: :destroy
has_many
:keys
,
dependent: :destroy
has_many
:emails
,
dependent: :destroy
has_many
:emails
,
dependent: :destroy
has_many
:identities
,
dependent: :destroy
has_many
:identities
,
dependent: :destroy
,
autosave:
true
# Groups
# Groups
has_many
:members
,
dependent: :destroy
has_many
:members
,
dependent: :destroy
...
...
db/migrate/20150817163600_deduplicate_user_identities.rb
0 → 100644
View file @
4d2f3611
class
DeduplicateUserIdentities
<
ActiveRecord
::
Migration
def
change
execute
'DROP TABLE IF EXISTS tt_migration_DeduplicateUserIdentities;'
execute
'CREATE TEMPORARY TABLE tt_migration_DeduplicateUserIdentities AS SELECT id,provider,user_id FROM identities;'
execute
'DELETE FROM identities WHERE id NOT IN ( SELECT MIN(id) FROM tt_migration_DeduplicateUserIdentities GROUP BY user_id, provider);'
execute
'DROP TABLE IF EXISTS tt_migration_DeduplicateUserIdentities;'
end
def
down
# This is an irreversible migration;
# If someone is trying to rollback for other reasons, we should not throw an Exception.
# raise ActiveRecord::IrreversibleMigration
end
end
db/schema.rb
View file @
4d2f3611
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2015081
20808
00
)
do
ActiveRecord
::
Schema
.
define
(
version:
2015081
71636
00
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
...
lib/gitlab/ldap/user.rb
View file @
4d2f3611
...
@@ -44,9 +44,13 @@ module Gitlab
...
@@ -44,9 +44,13 @@ module Gitlab
gl_user
.
skip_reconfirmation!
gl_user
.
skip_reconfirmation!
gl_user
.
email
=
auth_hash
.
email
gl_user
.
email
=
auth_hash
.
email
# Build new identity only if we dont have have same one
# If we don't have an identity for this provider yet, create one
gl_user
.
identities
.
find_or_initialize_by
(
provider:
auth_hash
.
provider
,
if
gl_user
.
identities
.
find_by
(
provider:
auth_hash
.
provider
).
nil?
extern_uid:
auth_hash
.
uid
)
gl_user
.
identities
.
new
(
extern_uid:
auth_hash
.
uid
,
provider:
auth_hash
.
provider
)
else
# Update the UID attribute for this provider in case it has changed
identity
=
gl_user
.
identities
.
select
{
|
identity
|
identity
.
provider
==
auth_hash
.
provider
}
identity
.
first
.
extern_uid
=
auth_hash
.
uid
end
gl_user
gl_user
end
end
...
...
spec/lib/gitlab/ldap/user_spec.rb
View file @
4d2f3611
...
@@ -47,6 +47,28 @@ describe Gitlab::LDAP::User do
...
@@ -47,6 +47,28 @@ describe Gitlab::LDAP::User do
expect
(
existing_user
.
ldap_identity
.
provider
).
to
eql
'ldapmain'
expect
(
existing_user
.
ldap_identity
.
provider
).
to
eql
'ldapmain'
end
end
it
'connects to existing ldap user if the extern_uid changes'
do
existing_user
=
create
(
:omniauth_user
,
email:
'john@example.com'
,
extern_uid:
'old-uid'
,
provider:
'ldapmain'
)
expect
{
ldap_user
.
save
}.
not_to
change
{
User
.
count
}
existing_user
.
reload
expect
(
existing_user
.
ldap_identity
.
extern_uid
).
to
eql
'my-uid'
expect
(
existing_user
.
ldap_identity
.
provider
).
to
eql
'ldapmain'
expect
(
existing_user
.
id
).
to
eql
ldap_user
.
gl_user
.
id
end
it
'maintains an identity per provider'
do
existing_user
=
create
(
:omniauth_user
,
email:
'john@example.com'
,
provider:
'twitter'
)
expect
(
existing_user
.
identities
.
count
).
to
eql
(
1
)
ldap_user
.
save
expect
(
ldap_user
.
gl_user
.
identities
.
count
).
to
eql
(
2
)
# Expect that find_by provider only returns a single instance of an identity and not an Enumerable
expect
(
ldap_user
.
gl_user
.
identities
.
find_by
(
provider:
'twitter'
)).
to
be_instance_of
Identity
expect
(
ldap_user
.
gl_user
.
identities
.
find_by
(
provider:
auth_hash
.
provider
)).
to
be_instance_of
Identity
end
it
"creates a new user if not found"
do
it
"creates a new user if not found"
do
expect
{
ldap_user
.
save
}.
to
change
{
User
.
count
}.
by
(
1
)
expect
{
ldap_user
.
save
}.
to
change
{
User
.
count
}.
by
(
1
)
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