diff --git a/lib/saml_idp/incoming_metadata.rb b/lib/saml_idp/incoming_metadata.rb index 250a5fea..5228eeac 100644 --- a/lib/saml_idp/incoming_metadata.rb +++ b/lib/saml_idp/incoming_metadata.rb @@ -94,9 +94,9 @@ def single_logout_services xpath( "//md:SPSSODescriptor/md:SingleLogoutService", md: metadata_namespace - ).reduce({}) do |hash, el| - hash[el["Binding"].to_s.split(":").last] = el["Location"] - hash + ).reduce([]) do |array, el| + props = el["Binding"].to_s.match /urn:oasis:names:tc:SAML:(?\S+):bindings:(?\S+)/ + array << { binding: props[:name], location: el["Location"], default: !!el["isDefault"], response_location: el["ResponseLocation"] } end end hashable :single_logout_services diff --git a/spec/lib/saml_idp/incoming_metadata_spec.rb b/spec/lib/saml_idp/incoming_metadata_spec.rb index fb00ec53..e6dbd74c 100644 --- a/spec/lib/saml_idp/incoming_metadata_spec.rb +++ b/spec/lib/saml_idp/incoming_metadata_spec.rb @@ -30,6 +30,24 @@ module SamlIdp eos + metadata_with_slo = <<-eos + + + + + urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified + + + + + eos + metadata_5 = <<-eos @@ -99,6 +117,17 @@ module SamlIdp expect(metadata.sign_authn_request).to eq(false) end + it 'should parse single logout url as array' do + metadata = SamlIdp::IncomingMetadata.new(metadata_with_slo) + expect(metadata.single_logout_services).to be_a(Array) + expect(metadata.single_logout_services.size).to eq(1) + expect(metadata.single_logout_services).to include( + hash_including(binding: "HTTP-Redirect"), + hash_including(location: "https://test/logout"), + hash_including(default: false) + ) + end + it 'should properly set unspecified_certificate when present' do metadata = SamlIdp::IncomingMetadata.new(metadata_5) expect(metadata.unspecified_certificate).to eq('MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnht3GR...')