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
dba65b24
Commit
dba65b24
authored
May 19, 2018
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SamlProvider settings extracted for use unconfigured
parent
0ec8038a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
26 deletions
+52
-26
ee/app/models/saml_provider.rb
ee/app/models/saml_provider.rb
+52
-26
No files found.
ee/app/models/saml_provider.rb
View file @
dba65b24
...
...
@@ -8,48 +8,74 @@ class SamlProvider < ActiveRecord::Base
after_initialize
:set_defaults
,
if: :new_record?
NAME_IDENTIFIER_FORMAT
=
'urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified'
.
freeze
delegate
:assertion_consumer_service_url
,
:issuer
,
:name_identifier_format
,
to: :settings
def
assertion_consumer_service_url
"
#{
full_group_path
}
/-/saml/callback"
def
certificate_fingerprint
=
(
value
)
super
(
strip_left_to_right_chars
(
value
))
end
def
issuer
full_group_pat
h
def
settings
ConfiguredOptions
.
new
(
self
).
to_
h
end
def
name_identifier_format
NAME_IDENTIFIER_FORMAT
end
class
DefaultOptions
NAME_IDENTIFIER_FORMAT
=
'urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified'
.
freeze
def
certificate_fingerprint
=
(
value
)
super
(
strip_left_to_right_chars
(
value
))
end
def
initialize
(
group_path
)
@group_path
=
group_path
end
def
settings
{
assertion_consumer_service_url:
assertion_consumer_service_url
,
issuer:
issuer
,
idp_cert_fingerprint:
certificate_fingerprint
,
idp_sso_target_url:
sso_url
,
name_identifier_format:
name_identifier_format
}
def
name_identifier_format
NAME_IDENTIFIER_FORMAT
end
def
full_group_path
"
#{
host
}
/groups/
#{
@group_path
}
"
end
def
issuer
full_group_path
end
def
assertion_consumer_service_url
"
#{
full_group_path
}
/-/saml/callback"
end
def
to_h
{
assertion_consumer_service_url:
assertion_consumer_service_url
,
issuer:
issuer
,
name_identifier_format:
name_identifier_format
}
end
private
def
host
@host
||=
Gitlab
.
config
.
gitlab
.
url
end
end
private
class
ConfiguredOptions
<
DefaultOptions
def
initialize
(
saml_provider
)
@group_path
=
saml_provider
.
group
.
full_path
@saml_provider
=
saml_provider
end
def
full_group_path
"
#{
host
}
/groups/
#{
group
.
full_path
}
"
def
to_h
super
.
merge
(
idp_cert_fingerprint:
@saml_provider
.
certificate_fingerprint
,
idp_sso_target_url:
@saml_provider
.
sso_url
)
end
end
private
def
set_defaults
self
.
enabled
=
true
end
def
host
@host
||=
Gitlab
.
config
.
gitlab
.
url
end
def
strip_left_to_right_chars
(
input
)
input
&
.
gsub
(
/[\u200E]/
,
''
)
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