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
50431f66
Commit
50431f66
authored
Oct 18, 2018
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor OmniAuth::Strategies::GroupSaml
Backports refactoring from Group SAML metadata MR
parent
6de9678b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
8 deletions
+25
-8
ee/lib/gitlab/auth/group_saml/group_lookup.rb
ee/lib/gitlab/auth/group_saml/group_lookup.rb
+4
-2
ee/lib/omni_auth/strategies/group_saml.rb
ee/lib/omni_auth/strategies/group_saml.rb
+14
-6
ee/spec/lib/omni_auth/strategies/group_saml_spec.rb
ee/spec/lib/omni_auth/strategies/group_saml_spec.rb
+7
-0
No files found.
ee/lib/gitlab/auth/group_saml/group_lookup.rb
View file @
50431f66
...
...
@@ -33,9 +33,11 @@ module Gitlab
path
.
match
(
path_regex
).
try
(
:[]
,
:group
)
end
def
path_from_params
params
=
Rack
::
Request
.
new
(
env
).
params
def
params
@params
||=
Rack
::
Request
.
new
(
env
).
params
end
def
path_from_params
params
[
'group_path'
]
end
end
...
...
ee/lib/omni_auth/strategies/group_saml.rb
View file @
50431f66
...
...
@@ -5,15 +5,11 @@ module OmniAuth
option
:callback_path
,
->
(
env
)
{
callback?
(
env
)
}
def
setup_phase
require_saml_provider
# Set devise scope for custom callback URL
env
[
"devise.mapping"
]
=
Devise
.
mappings
[
:user
]
group_lookup
=
Gitlab
::
Auth
::
GroupSaml
::
GroupLookup
.
new
(
env
)
unless
group_lookup
.
group_saml_enabled?
self
.
class
.
invalid_group!
(
group_lookup
.
path
)
end
settings
=
Gitlab
::
Auth
::
GroupSaml
::
DynamicSettings
.
new
(
group_lookup
.
group
).
to_h
env
[
'omniauth.strategy'
].
options
.
merge!
(
settings
)
...
...
@@ -33,6 +29,18 @@ module OmniAuth
def
self
.
callback?
(
env
)
env
[
'PATH_INFO'
]
=~
Gitlab
::
PathRegex
.
saml_callback_regex
end
private
def
group_lookup
@group_lookup
||=
Gitlab
::
Auth
::
GroupSaml
::
GroupLookup
.
new
(
env
)
end
def
require_saml_provider
unless
group_lookup
.
group_saml_enabled?
self
.
class
.
invalid_group!
(
group_lookup
.
path
)
end
end
end
end
end
ee/spec/lib/omni_auth/strategies/group_saml_spec.rb
View file @
50431f66
...
...
@@ -50,6 +50,13 @@ describe OmniAuth::Strategies::GroupSaml, type: :strategy do
expect
(
auth_hash
[
:info
][
'email'
]).
to
eq
(
"user@example.com"
)
end
it
'sets omniauth setings from configured settings'
do
post
"/groups/my-group/-/saml/callback"
,
SAMLResponse
:
saml_response
options
=
last_request
.
env
[
'omniauth.strategy'
].
options
expect
(
options
[
'idp_cert_fingerprint'
]).
to
eq
fingerprint
end
end
context
'with invalid SAMLResponse'
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