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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
1ab85b96
Commit
1ab85b96
authored
Jan 24, 2018
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only new users get marked as external
parent
d772f52e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
10 deletions
+27
-10
changelogs/unreleased/21554-mark-new-user-as-external.yml
changelogs/unreleased/21554-mark-new-user-as-external.yml
+5
-0
lib/gitlab/o_auth/user.rb
lib/gitlab/o_auth/user.rb
+1
-1
spec/lib/gitlab/o_auth/user_spec.rb
spec/lib/gitlab/o_auth/user_spec.rb
+21
-9
No files found.
changelogs/unreleased/21554-mark-new-user-as-external.yml
0 → 100644
View file @
1ab85b96
---
title
:
Login via OAuth now only marks new users as external
merge_request
:
16672
author
:
type
:
fixed
lib/gitlab/o_auth/user.rb
View file @
1ab85b96
...
...
@@ -55,7 +55,7 @@ module Gitlab
user
||=
find_or_build_ldap_user
if
auto_link_ldap_user?
user
||=
build_new_user
if
signup_enabled?
user
.
external
=
true
if
external_provider?
&&
user
user
.
external
=
true
if
external_provider?
&&
user
&
.
new_record?
user
end
...
...
spec/lib/gitlab/o_auth/user_spec.rb
View file @
1ab85b96
...
...
@@ -44,6 +44,18 @@ describe Gitlab::OAuth::User do
let
(
:provider
)
{
'twitter'
}
describe
'when account exists on server'
do
it
'does not mark the user as external'
do
create
(
:omniauth_user
,
extern_uid:
'my-uid'
,
provider:
provider
)
stub_omniauth_config
(
allow_single_sign_on:
[
provider
],
external_providers:
[
provider
])
oauth_user
.
save
expect
(
gl_user
).
to
be_valid
expect
(
gl_user
.
external
).
to
be_falsey
end
end
describe
'signup'
do
context
'when signup is disabled'
do
before
do
...
...
@@ -51,7 +63,7 @@ describe Gitlab::OAuth::User do
end
it
'creates the user'
do
stub_omniauth_config
(
allow_single_sign_on:
[
'twitter'
])
stub_omniauth_config
(
allow_single_sign_on:
[
provider
])
oauth_user
.
save
...
...
@@ -65,7 +77,7 @@ describe Gitlab::OAuth::User do
end
it
'creates and confirms the user anyway'
do
stub_omniauth_config
(
allow_single_sign_on:
[
'twitter'
])
stub_omniauth_config
(
allow_single_sign_on:
[
provider
])
oauth_user
.
save
...
...
@@ -75,7 +87,7 @@ describe Gitlab::OAuth::User do
end
it
'marks user as having password_automatically_set'
do
stub_omniauth_config
(
allow_single_sign_on:
[
'twitter'
],
external_providers:
[
'twitter'
])
stub_omniauth_config
(
allow_single_sign_on:
[
provider
],
external_providers:
[
provider
])
oauth_user
.
save
...
...
@@ -86,7 +98,7 @@ describe Gitlab::OAuth::User do
shared_examples
'to verify compliance with allow_single_sign_on'
do
context
'provider is marked as external'
do
it
'marks user as external'
do
stub_omniauth_config
(
allow_single_sign_on:
[
'twitter'
],
external_providers:
[
'twitter'
])
stub_omniauth_config
(
allow_single_sign_on:
[
provider
],
external_providers:
[
provider
])
oauth_user
.
save
expect
(
gl_user
).
to
be_valid
expect
(
gl_user
.
external
).
to
be_truthy
...
...
@@ -95,8 +107,8 @@ describe Gitlab::OAuth::User do
context
'provider was external, now has been removed'
do
it
'does not mark external user as internal'
do
create
(
:omniauth_user
,
extern_uid:
'my-uid'
,
provider:
'twitter'
,
external:
true
)
stub_omniauth_config
(
allow_single_sign_on:
[
'twitter'
],
external_providers:
[
'facebook'
])
create
(
:omniauth_user
,
extern_uid:
'my-uid'
,
provider:
provider
,
external:
true
)
stub_omniauth_config
(
allow_single_sign_on:
[
provider
],
external_providers:
[
'facebook'
])
oauth_user
.
save
expect
(
gl_user
).
to
be_valid
expect
(
gl_user
.
external
).
to
be_truthy
...
...
@@ -118,7 +130,7 @@ describe Gitlab::OAuth::User do
context
'with new allow_single_sign_on enabled syntax'
do
before
do
stub_omniauth_config
(
allow_single_sign_on:
[
'twitter'
])
stub_omniauth_config
(
allow_single_sign_on:
[
provider
])
end
it
"creates a user from Omniauth"
do
...
...
@@ -127,7 +139,7 @@ describe Gitlab::OAuth::User do
expect
(
gl_user
).
to
be_valid
identity
=
gl_user
.
identities
.
first
expect
(
identity
.
extern_uid
).
to
eql
uid
expect
(
identity
.
provider
).
to
eql
'twitter'
expect
(
identity
.
provider
).
to
eql
provider
end
end
...
...
@@ -142,7 +154,7 @@ describe Gitlab::OAuth::User do
expect
(
gl_user
).
to
be_valid
identity
=
gl_user
.
identities
.
first
expect
(
identity
.
extern_uid
).
to
eql
uid
expect
(
identity
.
provider
).
to
eql
'twitter'
expect
(
identity
.
provider
).
to
eql
provider
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