Skip to content

Commit 6f8046e

Browse files
committed
Adding idp_sso_service_url and idp_slo_service_url settings
1 parent 7808e03 commit 6f8046e

9 files changed

Lines changed: 103 additions & 55 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ def saml_settings
261261
settings.assertion_consumer_service_url = "http://#{request.host}/saml/consume"
262262
settings.sp_entity_id = "http://#{request.host}/saml/metadata"
263263
settings.idp_entity_id = "https://app.onelogin.com/saml/metadata/#{OneLoginAppId}"
264-
settings.idp_sso_target_url = "https://app.onelogin.com/trust/saml2/http-post/sso/#{OneLoginAppId}"
265-
settings.idp_slo_target_url = "https://app.onelogin.com/trust/saml2/http-redirect/slo/#{OneLoginAppId}"
264+
settings.idp_sso_service_url = "https://app.onelogin.com/trust/saml2/http-post/sso/#{OneLoginAppId}"
265+
settings.idp_slo_service_url = "https://app.onelogin.com/trust/saml2/http-redirect/slo/#{OneLoginAppId}"
266266
settings.idp_cert_fingerprint = OneLoginAppCertFingerPrint
267267
settings.idp_cert_fingerprint_algorithm = "http://www.w3.org/2000/09/xmldsig#sha1"
268268
settings.name_identifier_format = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
@@ -327,7 +327,7 @@ class SamlController < ApplicationController
327327
328328
settings.assertion_consumer_service_url = "http://#{request.host}/saml/consume"
329329
settings.sp_entity_id = "http://#{request.host}/saml/metadata"
330-
settings.idp_sso_target_url = "https://app.onelogin.com/saml/signon/#{OneLoginAppId}"
330+
settings.idp_sso_service_url = "https://app.onelogin.com/saml/signon/#{OneLoginAppId}"
331331
settings.idp_cert_fingerprint = OneLoginAppCertFingerPrint
332332
settings.name_identifier_format = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
333333
@@ -400,8 +400,8 @@ end
400400
The following attributes are set:
401401
* idp_entity_id
402402
* name_identifier_format
403-
* idp_sso_target_url
404-
* idp_slo_target_url
403+
* idp_sso_service_url
404+
* idp_slo_service_url
405405
* idp_attribute_names
406406
* idp_cert
407407
* idp_cert_fingerprint
@@ -623,7 +623,7 @@ def sp_logout_request
623623
# LogoutRequest accepts plain browser requests w/o paramters
624624
settings = saml_settings
625625
626-
if settings.idp_slo_target_url.nil?
626+
if settings.idp_slo_service_url.nil?
627627
logger.info "SLO IdP Endpoint not found in settings, executing then a normal logout'"
628628
delete_session
629629
else

lib/onelogin/ruby-saml/authrequest.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ def initialize
3131
#
3232
def create(settings, params = {})
3333
params = create_params(settings, params)
34-
params_prefix = (settings.idp_sso_target_url =~ /\?/) ? '&' : '?'
34+
params_prefix = (settings.idp_sso_service_url =~ /\?/) ? '&' : '?'
3535
saml_request = CGI.escape(params.delete("SAMLRequest"))
3636
request_params = "#{params_prefix}SAMLRequest=#{saml_request}"
3737
params.each_pair do |key, value|
3838
request_params << "&#{key.to_s}=#{CGI.escape(value.to_s)}"
3939
end
40-
raise SettingError.new "Invalid settings, idp_sso_target_url is not set!" if settings.idp_sso_target_url.nil? or settings.idp_sso_target_url.empty?
41-
@login_url = settings.idp_sso_target_url + request_params
40+
raise SettingError.new "Invalid settings, idp_sso_service_url is not set!" if settings.idp_sso_service_url.nil? or settings.idp_sso_service_url.empty?
41+
@login_url = settings.idp_sso_service_url + request_params
4242
end
4343

4444
# Creates the Get parameters for the request.
@@ -108,7 +108,7 @@ def create_xml_document(settings)
108108
root.attributes['ID'] = uuid
109109
root.attributes['IssueInstant'] = time
110110
root.attributes['Version'] = "2.0"
111-
root.attributes['Destination'] = settings.idp_sso_target_url unless settings.idp_sso_target_url.nil? or settings.idp_sso_target_url.empty?
111+
root.attributes['Destination'] = settings.idp_sso_service_url unless settings.idp_sso_service_url.nil? or settings.idp_sso_service_url.empty?
112112
root.attributes['IsPassive'] = settings.passive unless settings.passive.nil?
113113
root.attributes['ProtocolBinding'] = settings.protocol_binding unless settings.protocol_binding.nil?
114114
root.attributes["AttributeConsumingServiceIndex"] = settings.attributes_index unless settings.attributes_index.nil?

lib/onelogin/ruby-saml/idp_metadata_parser.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ def to_hash(options = {})
210210
{
211211
:idp_entity_id => @entity_id,
212212
:name_identifier_format => idp_name_id_format,
213-
:idp_sso_target_url => single_signon_service_url(options),
214-
:idp_slo_target_url => single_logout_service_url(options),
213+
:idp_sso_service_url => single_signon_service_url(options),
214+
:idp_slo_service_url => single_logout_service_url(options),
215215
:idp_attribute_names => attribute_names,
216216
:idp_cert => nil,
217217
:idp_cert_fingerprint => nil,

lib/onelogin/ruby-saml/settings.rb

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def initialize(overrides = {}, keep_security_attributes = false)
3131

3232
# IdP Data
3333
attr_accessor :idp_entity_id
34-
attr_accessor :idp_sso_target_url
35-
attr_accessor :idp_slo_target_url
34+
attr_accessor :idp_sso_service_url
35+
attr_accessor :idp_slo_service_url
3636
attr_accessor :idp_cert
3737
attr_accessor :idp_cert_fingerprint
3838
attr_accessor :idp_cert_fingerprint_algorithm
@@ -69,6 +69,36 @@ def initialize(overrides = {}, keep_security_attributes = false)
6969
attr_accessor :assertion_consumer_logout_service_url
7070
attr_accessor :assertion_consumer_logout_service_binding
7171
attr_accessor :issuer
72+
attr_accessor :idp_sso_target_url
73+
attr_accessor :idp_slo_target_url
74+
75+
# @return [String] IdP Single Sign On Service URL
76+
#
77+
def idp_sso_service_url
78+
val = nil
79+
if @idp_sso_service_url.nil?
80+
if @idp_sso_target_url
81+
val = @idp_sso_target_url
82+
end
83+
else
84+
val = @idp_sso_service_url
85+
end
86+
val
87+
end
88+
89+
# @return [String] IdP Single Logout Service URL
90+
#
91+
def idp_slo_service_url
92+
val = nil
93+
if @idp_slo_service_url.nil?
94+
if @idp_slo_target_url
95+
val = @idp_slo_target_url
96+
end
97+
else
98+
val = @idp_slo_service_url
99+
end
100+
val
101+
end
72102

73103
# @return [String] SP Entity ID
74104
#

test/idp_metadata_parser_test.rb

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ def initialize; end
2424
settings = idp_metadata_parser.parse(idp_metadata_descriptor)
2525

2626
assert_equal "https://hello.example.com/access/saml/idp.xml", settings.idp_entity_id
27-
assert_equal "https://hello.example.com/access/saml/login", settings.idp_sso_target_url
27+
assert_equal "https://hello.example.com/access/saml/login", settings.idp_sso_service_url
2828
assert_equal "F1:3C:6B:80:90:5A:03:0E:6C:91:3E:5D:15:FA:DD:B0:16:45:48:72", settings.idp_cert_fingerprint
29-
assert_equal "https://hello.example.com/access/saml/logout", settings.idp_slo_target_url
29+
assert_equal "https://hello.example.com/access/saml/logout", settings.idp_slo_service_url
3030
assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", settings.name_identifier_format
3131
assert_equal ["AuthToken", "SSOStartPage"], settings.idp_attribute_names
3232
assert_equal '2014-04-17T18:02:33.910Z', settings.valid_until
@@ -60,7 +60,7 @@ def initialize; end
6060
idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
6161
idp_metadata = idp_metadata_descriptor3
6262
settings = idp_metadata_parser.parse(idp_metadata)
63-
assert_equal "https://idp.example.com/idp/profile/Shibboleth/SSO", settings.idp_sso_target_url
63+
assert_equal "https://idp.example.com/idp/profile/Shibboleth/SSO", settings.idp_sso_service_url
6464
end
6565

6666
it "extract SSO endpoint with specific binding" do
@@ -69,15 +69,15 @@ def initialize; end
6969
options = {}
7070
options[:sso_binding] = ['urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST']
7171
settings = idp_metadata_parser.parse(idp_metadata, options)
72-
assert_equal "https://idp.example.com/idp/profile/SAML2/POST/SSO", settings.idp_sso_target_url
72+
assert_equal "https://idp.example.com/idp/profile/SAML2/POST/SSO", settings.idp_sso_service_url
7373

7474
options[:sso_binding] = ['urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect']
7575
settings = idp_metadata_parser.parse(idp_metadata, options)
76-
assert_equal "https://idp.example.com/idp/profile/SAML2/Redirect/SSO", settings.idp_sso_target_url
76+
assert_equal "https://idp.example.com/idp/profile/SAML2/Redirect/SSO", settings.idp_sso_service_url
7777

7878
options[:sso_binding] = ['invalid_binding', 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect']
7979
settings = idp_metadata_parser.parse(idp_metadata, options)
80-
assert_equal "https://idp.example.com/idp/profile/SAML2/Redirect/SSO", settings.idp_sso_target_url
80+
assert_equal "https://idp.example.com/idp/profile/SAML2/Redirect/SSO", settings.idp_sso_service_url
8181
end
8282

8383
it "uses settings options as hash for overrides" do
@@ -117,9 +117,9 @@ def initialize; end
117117
metadata = idp_metadata_parser.parse_to_hash(idp_metadata_descriptor)
118118

119119
assert_equal "https://hello.example.com/access/saml/idp.xml", metadata[:idp_entity_id]
120-
assert_equal "https://hello.example.com/access/saml/login", metadata[:idp_sso_target_url]
120+
assert_equal "https://hello.example.com/access/saml/login", metadata[:idp_sso_service_url]
121121
assert_equal "F1:3C:6B:80:90:5A:03:0E:6C:91:3E:5D:15:FA:DD:B0:16:45:48:72", metadata[:idp_cert_fingerprint]
122-
assert_equal "https://hello.example.com/access/saml/logout", metadata[:idp_slo_target_url]
122+
assert_equal "https://hello.example.com/access/saml/logout", metadata[:idp_slo_service_url]
123123
assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", metadata[:name_identifier_format]
124124
assert_equal ["AuthToken", "SSOStartPage"], metadata[:idp_attribute_names]
125125
assert_equal '2014-04-17T18:02:33.910Z', metadata[:valid_until]
@@ -153,7 +153,7 @@ def initialize; end
153153
idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
154154
idp_metadata = idp_metadata_descriptor3
155155
metadata = idp_metadata_parser.parse_to_hash(idp_metadata)
156-
assert_equal "https://idp.example.com/idp/profile/Shibboleth/SSO", metadata[:idp_sso_target_url]
156+
assert_equal "https://idp.example.com/idp/profile/Shibboleth/SSO", metadata[:idp_sso_service_url]
157157
end
158158

159159
it "extract SSO endpoint with specific binding" do
@@ -162,15 +162,15 @@ def initialize; end
162162
options = {}
163163
options[:sso_binding] = ['urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST']
164164
parsed_metadata = idp_metadata_parser.parse_to_hash(idp_metadata, options)
165-
assert_equal "https://idp.example.com/idp/profile/SAML2/POST/SSO", parsed_metadata[:idp_sso_target_url]
165+
assert_equal "https://idp.example.com/idp/profile/SAML2/POST/SSO", parsed_metadata[:idp_sso_service_url]
166166

167167
options[:sso_binding] = ['urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect']
168168
parsed_metadata = idp_metadata_parser.parse_to_hash(idp_metadata, options)
169-
assert_equal "https://idp.example.com/idp/profile/SAML2/Redirect/SSO", parsed_metadata[:idp_sso_target_url]
169+
assert_equal "https://idp.example.com/idp/profile/SAML2/Redirect/SSO", parsed_metadata[:idp_sso_service_url]
170170

171171
options[:sso_binding] = ['invalid_binding', 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect']
172172
parsed_metadata = idp_metadata_parser.parse_to_hash(idp_metadata, options)
173-
assert_equal "https://idp.example.com/idp/profile/SAML2/Redirect/SSO", parsed_metadata[:idp_sso_target_url]
173+
assert_equal "https://idp.example.com/idp/profile/SAML2/Redirect/SSO", parsed_metadata[:idp_sso_service_url]
174174
end
175175

176176
it "ignores a given :settings hash" do
@@ -207,8 +207,8 @@ def initialize; end
207207
settings = idp_metadata_parser.parse(idp_metadata_descriptor2)
208208

209209
assert_equal "https://hello.example.com/access/saml/idp.xml", settings.idp_entity_id
210-
assert_equal "https://hello.example.com/access/saml/login", settings.idp_sso_target_url
211-
assert_equal "https://hello.example.com/access/saml/logout", settings.idp_slo_target_url
210+
assert_equal "https://hello.example.com/access/saml/login", settings.idp_sso_service_url
211+
assert_equal "https://hello.example.com/access/saml/logout", settings.idp_slo_service_url
212212
assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", settings.name_identifier_format
213213
assert_equal ["AuthToken", "SSOStartPage"], settings.idp_attribute_names
214214

@@ -239,9 +239,9 @@ def initialize; end
239239
settings = idp_metadata_parser.parse_remote(@url)
240240

241241
assert_equal "https://hello.example.com/access/saml/idp.xml", settings.idp_entity_id
242-
assert_equal "https://hello.example.com/access/saml/login", settings.idp_sso_target_url
242+
assert_equal "https://hello.example.com/access/saml/login", settings.idp_sso_service_url
243243
assert_equal "F1:3C:6B:80:90:5A:03:0E:6C:91:3E:5D:15:FA:DD:B0:16:45:48:72", settings.idp_cert_fingerprint
244-
assert_equal "https://hello.example.com/access/saml/logout", settings.idp_slo_target_url
244+
assert_equal "https://hello.example.com/access/saml/logout", settings.idp_slo_service_url
245245
assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", settings.name_identifier_format
246246
assert_equal ["AuthToken", "SSOStartPage"], settings.idp_attribute_names
247247
assert_equal '2014-04-17T18:02:33.910Z', settings.valid_until
@@ -273,9 +273,9 @@ def initialize; end
273273
parsed_metadata = idp_metadata_parser.parse_remote_to_hash(@url)
274274

275275
assert_equal "https://hello.example.com/access/saml/idp.xml", parsed_metadata[:idp_entity_id]
276-
assert_equal "https://hello.example.com/access/saml/login", parsed_metadata[:idp_sso_target_url]
276+
assert_equal "https://hello.example.com/access/saml/login", parsed_metadata[:idp_sso_service_url]
277277
assert_equal "F1:3C:6B:80:90:5A:03:0E:6C:91:3E:5D:15:FA:DD:B0:16:45:48:72", parsed_metadata[:idp_cert_fingerprint]
278-
assert_equal "https://hello.example.com/access/saml/logout", parsed_metadata[:idp_slo_target_url]
278+
assert_equal "https://hello.example.com/access/saml/logout", parsed_metadata[:idp_slo_service_url]
279279
assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", parsed_metadata[:name_identifier_format]
280280
assert_equal ["AuthToken", "SSOStartPage"], parsed_metadata[:idp_attribute_names]
281281
assert_equal '2014-04-17T18:02:33.910Z', parsed_metadata[:valid_until]
@@ -341,9 +341,9 @@ def initialize; end
341341

342342
it "should retreive data" do
343343
assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", @settings.name_identifier_format
344-
assert_equal "https://hello.example.com/access/saml/login", @settings.idp_sso_target_url
344+
assert_equal "https://hello.example.com/access/saml/login", @settings.idp_sso_service_url
345345
assert_equal "F1:3C:6B:80:90:5A:03:0E:6C:91:3E:5D:15:FA:DD:B0:16:45:48:72", @settings.idp_cert_fingerprint
346-
assert_equal "https://hello.example.com/access/saml/logout", @settings.idp_slo_target_url
346+
assert_equal "https://hello.example.com/access/saml/logout", @settings.idp_slo_service_url
347347
assert_equal ["AuthToken", "SSOStartPage"], @settings.idp_attribute_names
348348
assert_equal '2014-04-17T18:02:33.910Z', @settings.valid_until
349349
end
@@ -434,8 +434,8 @@ def initialize; end
434434
assert_equal expected_multi_cert, @settings.idp_cert_multi
435435
assert_equal "https://idp.examle.com/saml/metadata", @settings.idp_entity_id
436436
assert_equal "urn:oasis:names:tc:SAML:2.0:nameid-format:transient", @settings.name_identifier_format
437-
assert_equal "https://idp.examle.com/saml/sso", @settings.idp_sso_target_url
438-
assert_equal "https://idp.examle.com/saml/slo", @settings.idp_slo_target_url
437+
assert_equal "https://idp.examle.com/saml/sso", @settings.idp_sso_service_url
438+
assert_equal "https://idp.examle.com/saml/slo", @settings.idp_slo_service_url
439439
end
440440
end
441441

@@ -479,8 +479,8 @@ def initialize; end
479479
assert_equal expected_multi_cert, @settings.idp_cert_multi
480480
assert_equal "https://idp.examle.com/saml/metadata", @settings.idp_entity_id
481481
assert_equal "urn:oasis:names:tc:SAML:2.0:nameid-format:transient", @settings.name_identifier_format
482-
assert_equal "https://idp.examle.com/saml/sso", @settings.idp_sso_target_url
483-
assert_equal "https://idp.examle.com/saml/slo", @settings.idp_slo_target_url
482+
assert_equal "https://idp.examle.com/saml/sso", @settings.idp_sso_service_url
483+
assert_equal "https://idp.examle.com/saml/slo", @settings.idp_slo_service_url
484484
end
485485
end
486486

@@ -519,8 +519,8 @@ def initialize; end
519519
assert_nil @settings.idp_cert_multi
520520
assert_equal "https://app.onelogin.com/saml/metadata/383123", @settings.idp_entity_id
521521
assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", @settings.name_identifier_format
522-
assert_equal "https://app.onelogin.com/trust/saml2/http-post/sso/383123", @settings.idp_sso_target_url
523-
assert_nil @settings.idp_slo_target_url
522+
assert_equal "https://app.onelogin.com/trust/saml2/http-post/sso/383123", @settings.idp_sso_service_url
523+
assert_nil @settings.idp_slo_service_url
524524
end
525525
end
526526

@@ -587,8 +587,8 @@ def initialize; end
587587
assert_equal expected_multi_cert, @settings.idp_cert_multi
588588
assert_equal "https://app.onelogin.com/saml/metadata/383123", @settings.idp_entity_id
589589
assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", @settings.name_identifier_format
590-
assert_equal "https://app.onelogin.com/trust/saml2/http-post/sso/383123", @settings.idp_sso_target_url
591-
assert_nil @settings.idp_slo_target_url
590+
assert_equal "https://app.onelogin.com/trust/saml2/http-post/sso/383123", @settings.idp_sso_service_url
591+
assert_nil @settings.idp_slo_service_url
592592
end
593593
end
594594
end

test/logout_responses/logoutresponse_fixtures.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ def settings
7777
:single_logout_service_url => "http://app.muda.no/sso/consume_logout",
7878
:issuer => "http://app.muda.no",
7979
:sp_name_qualifier => "http://sso.muda.no",
80-
:idp_sso_target_url => "http://sso.muda.no/sso",
81-
:idp_slo_target_url => "http://sso.muda.no/slo",
80+
:idp_sso_service_url => "http://sso.muda.no/sso",
81+
:idp_slo_service_url => "http://sso.muda.no/slo",
8282
:idp_cert_fingerprint => "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
8383
:name_identifier_format => "urn:oasis:names:tc:SAML:2.0:nameid-format:transient",
8484
}

0 commit comments

Comments
 (0)