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
104c8b89
Commit
104c8b89
authored
Dec 08, 2018
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport EE GroupSAML origin verification changes
parent
768475bd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
7 deletions
+14
-7
lib/gitlab/auth/omniauth_identity_linker_base.rb
lib/gitlab/auth/omniauth_identity_linker_base.rb
+5
-1
spec/controllers/omniauth_callbacks_controller_spec.rb
spec/controllers/omniauth_callbacks_controller_spec.rb
+1
-1
spec/support/helpers/login_helpers.rb
spec/support/helpers/login_helpers.rb
+8
-5
No files found.
lib/gitlab/auth/omniauth_identity_linker_base.rb
View file @
104c8b89
...
@@ -12,7 +12,7 @@ module Gitlab
...
@@ -12,7 +12,7 @@ module Gitlab
end
end
def
link
def
link
save
if
identity
.
new_recor
d?
save
if
unlinke
d?
end
end
def
changed?
def
changed?
...
@@ -35,6 +35,10 @@ module Gitlab
...
@@ -35,6 +35,10 @@ module Gitlab
@changed
=
identity
.
save
@changed
=
identity
.
save
end
end
def
unlinked?
identity
.
new_record?
end
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
identity
def
identity
@identity
||=
current_user
.
identities
@identity
||=
current_user
.
identities
...
...
spec/controllers/omniauth_callbacks_controller_spec.rb
View file @
104c8b89
...
@@ -170,7 +170,7 @@ describe OmniauthCallbacksController, type: :controller do
...
@@ -170,7 +170,7 @@ describe OmniauthCallbacksController, type: :controller do
before
do
before
do
stub_omniauth_saml_config
({
enabled:
true
,
auto_link_saml_user:
true
,
allow_single_sign_on:
[
'saml'
],
stub_omniauth_saml_config
({
enabled:
true
,
auto_link_saml_user:
true
,
allow_single_sign_on:
[
'saml'
],
providers:
[
saml_config
]
})
providers:
[
saml_config
]
})
mock_auth_hash
(
'saml'
,
'my-uid'
,
user
.
email
,
mock_saml_response
)
mock_auth_hash
_with_saml_xml
(
'saml'
,
'my-uid'
,
user
.
email
,
mock_saml_response
)
request
.
env
[
"devise.mapping"
]
=
Devise
.
mappings
[
:user
]
request
.
env
[
"devise.mapping"
]
=
Devise
.
mappings
[
:user
]
request
.
env
[
'omniauth.auth'
]
=
Rails
.
application
.
env_config
[
'omniauth.auth'
]
request
.
env
[
'omniauth.auth'
]
=
Rails
.
application
.
env_config
[
'omniauth.auth'
]
post
:saml
,
params:
{
SAMLResponse
:
mock_saml_response
}
post
:saml
,
params:
{
SAMLResponse
:
mock_saml_response
}
...
...
spec/support/helpers/login_helpers.rb
View file @
104c8b89
...
@@ -47,7 +47,7 @@ module LoginHelpers
...
@@ -47,7 +47,7 @@ module LoginHelpers
end
end
def
gitlab_sign_in_via
(
provider
,
user
,
uid
,
saml_response
=
nil
)
def
gitlab_sign_in_via
(
provider
,
user
,
uid
,
saml_response
=
nil
)
mock_auth_hash
(
provider
,
uid
,
user
.
email
,
saml_response
)
mock_auth_hash
_with_saml_xml
(
provider
,
uid
,
user
.
email
,
saml_response
)
visit
new_user_session_path
visit
new_user_session_path
click_link
provider
click_link
provider
end
end
...
@@ -87,7 +87,12 @@ module LoginHelpers
...
@@ -87,7 +87,12 @@ module LoginHelpers
click_link
"oauth-login-
#{
provider
}
"
click_link
"oauth-login-
#{
provider
}
"
end
end
def
mock_auth_hash
(
provider
,
uid
,
email
,
saml_response
=
nil
)
def
mock_auth_hash_with_saml_xml
(
provider
,
uid
,
email
,
saml_response
)
response_object
=
{
document:
saml_xml
(
saml_response
)
}
mock_auth_hash
(
provider
,
uid
,
email
,
response_object:
response_object
)
end
def
mock_auth_hash
(
provider
,
uid
,
email
,
response_object:
nil
)
# The mock_auth configuration allows you to set per-provider (or default)
# The mock_auth configuration allows you to set per-provider (or default)
# authentication hashes to return during integration testing.
# authentication hashes to return during integration testing.
OmniAuth
.
config
.
mock_auth
[
provider
.
to_sym
]
=
OmniAuth
::
AuthHash
.
new
({
OmniAuth
.
config
.
mock_auth
[
provider
.
to_sym
]
=
OmniAuth
::
AuthHash
.
new
({
...
@@ -110,9 +115,7 @@ module LoginHelpers
...
@@ -110,9 +115,7 @@ module LoginHelpers
image:
'mock_user_thumbnail_url'
image:
'mock_user_thumbnail_url'
}
}
},
},
response_object:
{
response_object:
response_object
document:
saml_xml
(
saml_response
)
}
}
}
})
})
Rails
.
application
.
env_config
[
'omniauth.auth'
]
=
OmniAuth
.
config
.
mock_auth
[
provider
.
to_sym
]
Rails
.
application
.
env_config
[
'omniauth.auth'
]
=
OmniAuth
.
config
.
mock_auth
[
provider
.
to_sym
]
...
...
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