Skip to content

Commit 39bd342

Browse files
authored
Merge pull request #575 from mentimeter/fix_slo_logoutresponse
Fix error in 1.12 that breaks SloLogoutresponse and LogoutRequest
2 parents 79fc1d7 + 9186660 commit 39bd342

File tree

6 files changed

+16
-18
lines changed

6 files changed

+16
-18
lines changed

lib/onelogin/ruby-saml/logoutrequest.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ def request_id
3232
#
3333
def create(settings, params={})
3434
params = create_params(settings, params)
35-
params_prefix = (settings.idp_slo_target_url =~ /\?/) ? '&' : '?'
35+
params_prefix = (settings.idp_slo_service_url =~ /\?/) ? '&' : '?'
3636
saml_request = CGI.escape(params.delete("SAMLRequest"))
3737
request_params = "#{params_prefix}SAMLRequest=#{saml_request}"
3838
params.each_pair do |key, value|
3939
request_params << "&#{key.to_s}=#{CGI.escape(value.to_s)}"
4040
end
41-
raise SettingError.new "Invalid settings, idp_slo_target_url is not set!" if settings.idp_slo_target_url.nil? or settings.idp_slo_target_url.empty?
42-
@logout_url = settings.idp_slo_target_url + request_params
41+
raise SettingError.new "Invalid settings, idp_slo_service_url is not set!" if settings.idp_slo_service_url.nil? or settings.idp_slo_service_url.empty?
42+
@logout_url = settings.idp_slo_service_url + request_params
4343
end
4444

4545
# Creates the Get parameters for the logout request.
@@ -109,7 +109,7 @@ def create_xml_document(settings)
109109
root.attributes['ID'] = uuid
110110
root.attributes['IssueInstant'] = time
111111
root.attributes['Version'] = "2.0"
112-
root.attributes['Destination'] = settings.idp_slo_target_url unless settings.idp_slo_target_url.nil? or settings.idp_slo_target_url.empty?
112+
root.attributes['Destination'] = settings.idp_slo_service_url unless settings.idp_slo_service_url.nil? or settings.idp_slo_service_url.empty?
113113

114114
if settings.sp_entity_id
115115
issuer = root.add_element "saml:Issuer"

lib/onelogin/ruby-saml/slo_logoutresponse.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ def response_id
3636
#
3737
def create(settings, request_id = nil, logout_message = nil, params = {}, logout_status_code = nil)
3838
params = create_params(settings, request_id, logout_message, params, logout_status_code)
39-
params_prefix = (settings.idp_slo_target_url =~ /\?/) ? '&' : '?'
40-
url = settings.idp_slo_response_service_url || settings.idp_slo_target_url
39+
params_prefix = (settings.idp_slo_service_url =~ /\?/) ? '&' : '?'
40+
url = settings.idp_slo_response_service_url || settings.idp_slo_service_url
4141
saml_response = CGI.escape(params.delete("SAMLResponse"))
4242
response_params = "#{params_prefix}SAMLResponse=#{saml_response}"
4343
params.each_pair do |key, value|
4444
response_params << "&#{key.to_s}=#{CGI.escape(value.to_s)}"
4545
end
4646

47-
raise SettingError.new "Invalid settings, idp_slo_target_url is not set!" if url.nil? or url.empty?
47+
raise SettingError.new "Invalid settings, idp_slo_service_url is not set!" if url.nil? or url.empty?
4848
@logout_url = url + response_params
4949
end
5050

@@ -117,7 +117,8 @@ def create_xml_document(settings, request_id = nil, logout_message = nil, status
117117
response_doc = XMLSecurity::Document.new
118118
response_doc.uuid = uuid
119119

120-
destination = settings.idp_slo_response_service_url || settings.idp_slo_target_url
120+
destination = settings.idp_slo_response_service_url || settings.idp_slo_service_url
121+
121122

122123
root = response_doc.add_element 'samlp:LogoutResponse', { 'xmlns:samlp' => 'urn:oasis:names:tc:SAML:2.0:protocol', "xmlns:saml" => "urn:oasis:names:tc:SAML:2.0:assertion" }
123124
root.attributes['ID'] = uuid

test/logoutrequest_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class RequestTest < Minitest::Test
88
let(:settings) { OneLogin::RubySaml::Settings.new }
99

1010
before do
11-
settings.idp_slo_target_url = "http://unauth.com/logout"
11+
settings.idp_slo_service_url = "http://unauth.com/logout"
1212
settings.name_identifier_value = "f00f00"
1313
end
1414

@@ -43,7 +43,7 @@ class RequestTest < Minitest::Test
4343
end
4444

4545
it "set sessionindex" do
46-
settings.idp_slo_target_url = "http://example.com"
46+
settings.idp_slo_service_url = "http://example.com"
4747
sessionidx = OneLogin::RubySaml::Utils.uuid
4848
settings.sessionindex = sessionidx
4949

@@ -75,7 +75,7 @@ class RequestTest < Minitest::Test
7575

7676
describe "when the target url contains a query string" do
7777
it "create the SAMLRequest parameter correctly" do
78-
settings.idp_slo_target_url = "http://example.com?field=value"
78+
settings.idp_slo_service_url = "http://example.com?field=value"
7979

8080
unauth_url = OneLogin::RubySaml::Logoutrequest.new.create(settings)
8181
assert_match /^http:\/\/example.com\?field=value&SAMLRequest/, unauth_url
@@ -84,7 +84,7 @@ class RequestTest < Minitest::Test
8484

8585
describe "consumation of logout may need to track the transaction" do
8686
it "have access to the request uuid" do
87-
settings.idp_slo_target_url = "http://example.com?field=value"
87+
settings.idp_slo_service_url = "http://example.com?field=value"
8888

8989
unauth_req = OneLogin::RubySaml::Logoutrequest.new
9090
unauth_url = unauth_req.create(settings)

test/logoutresponse_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class RubySamlTest < Minitest::Test
225225

226226
before do
227227
settings.soft = true
228-
settings.idp_slo_target_url = "http://example.com?field=value"
228+
settings.idp_slo_service_url = "http://example.com?field=value"
229229
settings.security[:logout_responses_signed] = true
230230
settings.security[:embed_sign] = false
231231
settings.certificate = ruby_saml_cert_text
@@ -373,7 +373,7 @@ class RubySamlTest < Minitest::Test
373373

374374
before do
375375
settings.soft = true
376-
settings.idp_slo_target_url = "http://example.com?field=value"
376+
settings.idp_slo_service_url = "http://example.com?field=value"
377377
settings.security[:signature_method] = XMLSecurity::Document::RSA_SHA1
378378
settings.security[:logout_responses_signed] = true
379379
settings.security[:embed_sign] = false

test/slo_logoutrequest_test.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ class RubySamlTest < Minitest::Test
5454

5555
it "collect errors when collect_errors=true" do
5656
settings.idp_entity_id = 'http://idp.example.com/invalid'
57-
settings.idp_slo_target_url = "http://example.com?field=value"
5857
settings.security[:logout_requests_signed] = true
5958
settings.security[:embed_sign] = false
6059
settings.certificate = ruby_saml_cert_text
@@ -247,7 +246,6 @@ class RubySamlTest < Minitest::Test
247246

248247
describe "#validate_signature" do
249248
before do
250-
settings.idp_slo_target_url = "http://example.com?field=value"
251249
settings.security[:logout_requests_signed] = true
252250
settings.security[:embed_sign] = false
253251
settings.certificate = ruby_saml_cert_text
@@ -406,7 +404,6 @@ class RubySamlTest < Minitest::Test
406404

407405
describe "#validate_signature with multiple idp certs" do
408406
before do
409-
settings.idp_slo_target_url = "http://example.com?field=value"
410407
settings.certificate = ruby_saml_cert_text
411408
settings.private_key = ruby_saml_key_text
412409
settings.idp_cert = nil

test/slo_logoutresponse_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class SloLogoutresponseTest < Minitest::Test
1010

1111
before do
1212
settings.idp_entity_id = 'https://app.onelogin.com/saml/metadata/SOMEACCOUNT'
13-
settings.idp_slo_target_url = "http://unauth.com/logout"
13+
settings.idp_slo_service_url = "http://unauth.com/logout"
1414
settings.name_identifier_value = "f00f00"
1515
settings.compress_request = true
1616
settings.certificate = ruby_saml_cert_text

0 commit comments

Comments
 (0)