Skip to content

Commit

Permalink
Use idp_slo_service_url instead of idp_slo_target_url in LogoutRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
JCB-K committed Mar 4, 2021
1 parent 5a27c4c commit 9186660
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/onelogin/ruby-saml/logoutrequest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ def request_id
#
def create(settings, params={})
params = create_params(settings, params)
params_prefix = (settings.idp_slo_target_url =~ /\?/) ? '&' : '?'
params_prefix = (settings.idp_slo_service_url =~ /\?/) ? '&' : '?'
saml_request = CGI.escape(params.delete("SAMLRequest"))
request_params = "#{params_prefix}SAMLRequest=#{saml_request}"
params.each_pair do |key, value|
request_params << "&#{key.to_s}=#{CGI.escape(value.to_s)}"
end
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?
@logout_url = settings.idp_slo_target_url + request_params
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?
@logout_url = settings.idp_slo_service_url + request_params
end

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

if settings.sp_entity_id
issuer = root.add_element "saml:Issuer"
Expand Down
8 changes: 4 additions & 4 deletions test/logoutrequest_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class RequestTest < Minitest::Test
let(:settings) { OneLogin::RubySaml::Settings.new }

before do
settings.idp_slo_target_url = "http://unauth.com/logout"
settings.idp_slo_service_url = "http://unauth.com/logout"
settings.name_identifier_value = "f00f00"
end

Expand Down Expand Up @@ -43,7 +43,7 @@ class RequestTest < Minitest::Test
end

it "set sessionindex" do
settings.idp_slo_target_url = "http://example.com"
settings.idp_slo_service_url = "http://example.com"
sessionidx = OneLogin::RubySaml::Utils.uuid
settings.sessionindex = sessionidx

Expand Down Expand Up @@ -75,7 +75,7 @@ class RequestTest < Minitest::Test

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

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

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

unauth_req = OneLogin::RubySaml::Logoutrequest.new
unauth_url = unauth_req.create(settings)
Expand Down

0 comments on commit 9186660

Please sign in to comment.