ruby-saml 1.11.0 → 1.12.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ruby-saml might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/.travis.yml +14 -12
- data/README.md +76 -22
- data/changelog.md +27 -0
- data/lib/onelogin/ruby-saml/attributes.rb +24 -1
- data/lib/onelogin/ruby-saml/authrequest.rb +9 -4
- data/lib/onelogin/ruby-saml/idp_metadata_parser.rb +62 -24
- data/lib/onelogin/ruby-saml/logoutrequest.rb +7 -1
- data/lib/onelogin/ruby-saml/logoutresponse.rb +4 -0
- data/lib/onelogin/ruby-saml/metadata.rb +9 -1
- data/lib/onelogin/ruby-saml/response.rb +38 -16
- data/lib/onelogin/ruby-saml/saml_message.rb +6 -0
- data/lib/onelogin/ruby-saml/setting_error.rb +6 -0
- data/lib/onelogin/ruby-saml/settings.rb +34 -2
- data/lib/onelogin/ruby-saml/slo_logoutrequest.rb +4 -0
- data/lib/onelogin/ruby-saml/slo_logoutresponse.rb +27 -14
- data/lib/onelogin/ruby-saml/utils.rb +56 -0
- data/lib/onelogin/ruby-saml/version.rb +1 -1
- data/lib/xml_security.rb +34 -6
- data/ruby-saml.gemspec +8 -4
- metadata +22 -282
- data/test/certificates/certificate.der +0 -0
- data/test/certificates/certificate1 +0 -12
- data/test/certificates/certificate_without_head_foot +0 -1
- data/test/certificates/formatted_certificate +0 -14
- data/test/certificates/formatted_chained_certificate +0 -42
- data/test/certificates/formatted_private_key +0 -12
- data/test/certificates/formatted_rsa_private_key +0 -12
- data/test/certificates/invalid_certificate1 +0 -1
- data/test/certificates/invalid_certificate2 +0 -1
- data/test/certificates/invalid_certificate3 +0 -12
- data/test/certificates/invalid_chained_certificate1 +0 -1
- data/test/certificates/invalid_private_key1 +0 -1
- data/test/certificates/invalid_private_key2 +0 -1
- data/test/certificates/invalid_private_key3 +0 -10
- data/test/certificates/invalid_rsa_private_key1 +0 -1
- data/test/certificates/invalid_rsa_private_key2 +0 -1
- data/test/certificates/invalid_rsa_private_key3 +0 -10
- data/test/certificates/ruby-saml-2.crt +0 -15
- data/test/certificates/ruby-saml.crt +0 -14
- data/test/certificates/ruby-saml.key +0 -15
- data/test/idp_metadata_parser_test.rb +0 -594
- data/test/logging_test.rb +0 -62
- data/test/logout_requests/invalid_slo_request.xml +0 -6
- data/test/logout_requests/slo_request.xml +0 -4
- data/test/logout_requests/slo_request.xml.base64 +0 -1
- data/test/logout_requests/slo_request_deflated.xml.base64 +0 -1
- data/test/logout_requests/slo_request_with_name_id_format.xml +0 -4
- data/test/logout_requests/slo_request_with_session_index.xml +0 -5
- data/test/logout_responses/logoutresponse_fixtures.rb +0 -86
- data/test/logoutrequest_test.rb +0 -260
- data/test/logoutresponse_test.rb +0 -427
- data/test/metadata/idp_descriptor.xml +0 -26
- data/test/metadata/idp_descriptor_2.xml +0 -56
- data/test/metadata/idp_descriptor_3.xml +0 -14
- data/test/metadata/idp_descriptor_4.xml +0 -72
- data/test/metadata/idp_metadata_different_sign_and_encrypt_cert.xml +0 -72
- data/test/metadata/idp_metadata_multi_certs.xml +0 -75
- data/test/metadata/idp_metadata_multi_signing_certs.xml +0 -52
- data/test/metadata/idp_metadata_same_sign_and_encrypt_cert.xml +0 -71
- data/test/metadata/idp_multiple_descriptors.xml +0 -59
- data/test/metadata/idp_multiple_descriptors_2.xml +0 -59
- data/test/metadata/no_idp_descriptor.xml +0 -21
- data/test/metadata_test.rb +0 -331
- data/test/request_test.rb +0 -340
- data/test/response_test.rb +0 -1629
- data/test/responses/adfs_response_sha1.xml +0 -46
- data/test/responses/adfs_response_sha256.xml +0 -46
- data/test/responses/adfs_response_sha384.xml +0 -46
- data/test/responses/adfs_response_sha512.xml +0 -46
- data/test/responses/adfs_response_xmlns.xml +0 -45
- data/test/responses/attackxee.xml +0 -13
- data/test/responses/invalids/duplicated_attributes.xml.base64 +0 -1
- data/test/responses/invalids/empty_destination.xml.base64 +0 -1
- data/test/responses/invalids/empty_nameid.xml.base64 +0 -1
- data/test/responses/invalids/encrypted_new_attack.xml.base64 +0 -1
- data/test/responses/invalids/invalid_audience.xml.base64 +0 -1
- data/test/responses/invalids/invalid_issuer_assertion.xml.base64 +0 -1
- data/test/responses/invalids/invalid_issuer_message.xml.base64 +0 -1
- data/test/responses/invalids/invalid_signature_position.xml.base64 +0 -1
- data/test/responses/invalids/invalid_subjectconfirmation_inresponse.xml.base64 +0 -1
- data/test/responses/invalids/invalid_subjectconfirmation_nb.xml.base64 +0 -1
- data/test/responses/invalids/invalid_subjectconfirmation_noa.xml.base64 +0 -1
- data/test/responses/invalids/invalid_subjectconfirmation_recipient.xml.base64 +0 -1
- data/test/responses/invalids/multiple_assertions.xml.base64 +0 -2
- data/test/responses/invalids/multiple_signed.xml.base64 +0 -1
- data/test/responses/invalids/no_authnstatement.xml.base64 +0 -1
- data/test/responses/invalids/no_conditions.xml.base64 +0 -1
- data/test/responses/invalids/no_id.xml.base64 +0 -1
- data/test/responses/invalids/no_issuer_assertion.xml.base64 +0 -1
- data/test/responses/invalids/no_issuer_response.xml.base64 +0 -1
- data/test/responses/invalids/no_nameid.xml.base64 +0 -1
- data/test/responses/invalids/no_saml2.xml.base64 +0 -1
- data/test/responses/invalids/no_signature.xml.base64 +0 -1
- data/test/responses/invalids/no_status.xml.base64 +0 -1
- data/test/responses/invalids/no_status_code.xml.base64 +0 -1
- data/test/responses/invalids/no_subjectconfirmation_data.xml.base64 +0 -1
- data/test/responses/invalids/no_subjectconfirmation_method.xml.base64 +0 -1
- data/test/responses/invalids/response_invalid_signed_element.xml.base64 +0 -1
- data/test/responses/invalids/response_with_concealed_signed_assertion.xml +0 -51
- data/test/responses/invalids/response_with_doubled_signed_assertion.xml +0 -49
- data/test/responses/invalids/signature_wrapping_attack.xml.base64 +0 -1
- data/test/responses/invalids/status_code_responder.xml.base64 +0 -1
- data/test/responses/invalids/status_code_responer_and_msg.xml.base64 +0 -1
- data/test/responses/invalids/wrong_spnamequalifier.xml.base64 +0 -1
- data/test/responses/no_signature_ns.xml +0 -48
- data/test/responses/open_saml_response.xml +0 -56
- data/test/responses/response_assertion_wrapped.xml.base64 +0 -93
- data/test/responses/response_audience_self_closed_tag.xml.base64 +0 -1
- data/test/responses/response_double_status_code.xml.base64 +0 -1
- data/test/responses/response_encrypted_attrs.xml.base64 +0 -1
- data/test/responses/response_encrypted_nameid.xml.base64 +0 -1
- data/test/responses/response_eval.xml +0 -7
- data/test/responses/response_no_cert_and_encrypted_attrs.xml +0 -29
- data/test/responses/response_node_text_attack.xml.base64 +0 -1
- data/test/responses/response_node_text_attack2.xml.base64 +0 -1
- data/test/responses/response_node_text_attack3.xml.base64 +0 -1
- data/test/responses/response_unsigned_xml_base64 +0 -1
- data/test/responses/response_with_ampersands.xml +0 -139
- data/test/responses/response_with_ampersands.xml.base64 +0 -93
- data/test/responses/response_with_ds_namespace_at_the_root.xml.base64 +0 -1
- data/test/responses/response_with_multiple_attribute_statements.xml +0 -72
- data/test/responses/response_with_multiple_attribute_values.xml +0 -67
- data/test/responses/response_with_retrieval_method.xml +0 -26
- data/test/responses/response_with_saml2_namespace.xml.base64 +0 -102
- data/test/responses/response_with_signed_assertion.xml.base64 +0 -66
- data/test/responses/response_with_signed_assertion_2.xml.base64 +0 -1
- data/test/responses/response_with_signed_assertion_3.xml +0 -30
- data/test/responses/response_with_signed_message_and_assertion.xml +0 -34
- data/test/responses/response_with_undefined_recipient.xml.base64 +0 -1
- data/test/responses/response_without_attributes.xml.base64 +0 -79
- data/test/responses/response_without_reference_uri.xml.base64 +0 -1
- data/test/responses/response_wrapped.xml.base64 +0 -150
- data/test/responses/signed_message_encrypted_signed_assertion.xml.base64 +0 -1
- data/test/responses/signed_message_encrypted_unsigned_assertion.xml.base64 +0 -1
- data/test/responses/signed_nameid_in_atts.xml +0 -47
- data/test/responses/signed_unqual_nameid_in_atts.xml +0 -47
- data/test/responses/simple_saml_php.xml +0 -71
- data/test/responses/starfield_response.xml.base64 +0 -1
- data/test/responses/test_sign.xml +0 -43
- data/test/responses/unsigned_encrypted_adfs.xml +0 -23
- data/test/responses/unsigned_message_aes128_encrypted_signed_assertion.xml.base64 +0 -1
- data/test/responses/unsigned_message_aes192_encrypted_signed_assertion.xml.base64 +0 -1
- data/test/responses/unsigned_message_aes256_encrypted_signed_assertion.xml.base64 +0 -1
- data/test/responses/unsigned_message_des192_encrypted_signed_assertion.xml.base64 +0 -1
- data/test/responses/unsigned_message_encrypted_assertion_without_saml_namespace.xml.base64 +0 -1
- data/test/responses/unsigned_message_encrypted_signed_assertion.xml.base64 +0 -1
- data/test/responses/unsigned_message_encrypted_unsigned_assertion.xml.base64 +0 -1
- data/test/responses/valid_response.xml.base64 +0 -1
- data/test/responses/valid_response_with_formatted_x509certificate.xml.base64 +0 -1
- data/test/responses/valid_response_without_x509certificate.xml.base64 +0 -1
- data/test/saml_message_test.rb +0 -56
- data/test/settings_test.rb +0 -338
- data/test/slo_logoutrequest_test.rb +0 -467
- data/test/slo_logoutresponse_test.rb +0 -233
- data/test/test_helper.rb +0 -333
- data/test/utils_test.rb +0 -259
- data/test/xml_security_test.rb +0 -421
@@ -1,4 +0,0 @@
|
|
1
|
-
<samlp:LogoutRequest Version='2.0' ID='_c0348950-935b-0131-1060-782bcb56fcaa' xmlns:samlp='urn:oasis:names:tc:SAML:2.0:protocol' IssueInstant='2014-03-21T19:20:13'>
|
2
|
-
<saml:Issuer xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'>https://app.onelogin.com/saml/metadata/SOMEACCOUNT</saml:Issuer>
|
3
|
-
<saml:NameID xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'>someone@example.org</saml:NameID>
|
4
|
-
</samlp:LogoutRequest>
|
@@ -1 +0,0 @@
|
|
1
|
-
PHNhbWxwOkxvZ291dFJlcXVlc3QgVmVyc2lvbj0nMi4wJyBJRD0nX2MwMzQ4OTUwLTkzNWItMDEzMS0xMDYwLTc4MmJjYjU2ZmNhYScgeG1sbnM6c2FtbHA9J3VybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDpwcm90b2NvbCcgSXNzdWVJbnN0YW50PScyMDE0LTAzLTIxVDE5OjIwOjEzJz4NCiAgPHNhbWw6SXNzdWVyIHhtbG5zOnNhbWw9J3VybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDphc3NlcnRpb24nPmh0dHBzOi8vYXBwLm9uZWxvZ2luLmNvbS9zYW1sL21ldGFkYXRhL1NPTUVBQ0NPVU5UPC9zYW1sOklzc3Vlcj4NCiAgPHNhbWw6TmFtZUlEIHhtbG5zOnNhbWw9J3VybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMDphc3NlcnRpb24nPnNvbWVvbmVAZXhhbXBsZS5vcmc8L3NhbWw6TmFtZUlEPg0KPC9zYW1scDpMb2dvdXRSZXF1ZXN0Pg==
|
@@ -1 +0,0 @@
|
|
1
|
-
ndG7asMwFIDhvdB38KZJlmTHaSxs05B0COQCTdq1yKrqGqxLdWTI41dJOpgOHToKDv93DqpA6MHxre3sGJ7V16ggJK/KQ29NjbKUomSzrtGbpPlsURYUl3nRYspyhhmdU/ywyFrZFvMPKQRKznowwK/JGo3ecCugB26EVsCD5MflbstjlDtvg5V2iHWAUW0MBGFCBCmbYZrjjJ1YyTPKWY6a+7skqS5Rfh32E+ZvRQAoH+IlqPkMwQEnRDiXWqMG2/UmlVaTS4VoFcS7CIIcD7un5Wp1eNmfKjIhJzvsI7NZ/2cHsFpF+1GdhXaDSq3vfpBbMyK396//aL4B
|
@@ -1,4 +0,0 @@
|
|
1
|
-
<samlp:LogoutRequest Version='2.0' ID='_c0348950-935b-0131-1060-782bcb56fcaa' xmlns:samlp='urn:oasis:names:tc:SAML:2.0:protocol' IssueInstant='2014-03-21T19:20:13'>
|
2
|
-
<saml:Issuer xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'>https://app.onelogin.com/saml/metadata/SOMEACCOUNT</saml:Issuer>
|
3
|
-
<saml:NameID xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion' Format='urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress'>someone@example.org</saml:NameID>
|
4
|
-
</samlp:LogoutRequest>
|
@@ -1,5 +0,0 @@
|
|
1
|
-
<samlp:LogoutRequest Version='2.0' ID='_c0348950-935b-0131-1060-782bcb56fcaa' xmlns:samlp='urn:oasis:names:tc:SAML:2.0:protocol' IssueInstant='2014-03-21T19:20:13'>
|
2
|
-
<saml:Issuer xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'>https://app.onelogin.com/saml/metadata/SOMEACCOUNT</saml:Issuer>
|
3
|
-
<saml:NameID xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'>someone@example.org</saml:NameID>
|
4
|
-
<samlp:SessionIndex>_ea853497-c58a-408a-bc23-c849752d9741</samlp:SessionIndex>
|
5
|
-
</samlp:LogoutRequest>
|
@@ -1,86 +0,0 @@
|
|
1
|
-
#encoding: utf-8
|
2
|
-
|
3
|
-
def default_logout_response_opts
|
4
|
-
{
|
5
|
-
:uuid => "_28024690-000e-0130-b6d2-38f6b112be8b",
|
6
|
-
:issue_instant => Time.now.strftime('%Y-%m-%dT%H:%M:%SZ'),
|
7
|
-
:settings => settings
|
8
|
-
}
|
9
|
-
end
|
10
|
-
|
11
|
-
def valid_logout_response_document(opts = {})
|
12
|
-
opts = default_logout_response_opts.merge(opts)
|
13
|
-
|
14
|
-
"<samlp:LogoutResponse
|
15
|
-
xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\"
|
16
|
-
ID=\"#{random_id}\" Version=\"2.0\"
|
17
|
-
IssueInstant=\"#{opts[:issue_instant]}\"
|
18
|
-
Destination=\"#{opts[:settings].single_logout_service_url}\"
|
19
|
-
InResponseTo=\"#{opts[:uuid]}\">
|
20
|
-
<saml:Issuer xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\">#{opts[:settings].issuer}</saml:Issuer>
|
21
|
-
<samlp:Status xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\">
|
22
|
-
<samlp:StatusCode xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\"
|
23
|
-
Value=\"urn:oasis:names:tc:SAML:2.0:status:Success\">
|
24
|
-
</samlp:StatusCode>
|
25
|
-
</samlp:Status>
|
26
|
-
</samlp:LogoutResponse>"
|
27
|
-
end
|
28
|
-
|
29
|
-
def unsuccessful_logout_response_document(opts = {})
|
30
|
-
opts = default_logout_response_opts.merge(opts)
|
31
|
-
|
32
|
-
"<samlp:LogoutResponse
|
33
|
-
xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\"
|
34
|
-
ID=\"#{random_id}\" Version=\"2.0\"
|
35
|
-
IssueInstant=\"#{opts[:issue_instant]}\"
|
36
|
-
Destination=\"#{opts[:settings].single_logout_service_url}\"
|
37
|
-
InResponseTo=\"#{opts[:uuid]}\">
|
38
|
-
<saml:Issuer xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\">#{opts[:settings].issuer}</saml:Issuer>
|
39
|
-
<samlp:Status xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\">
|
40
|
-
<samlp:StatusCode xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\"
|
41
|
-
Value=\"urn:oasis:names:tc:SAML:2.0:status:Requester\">
|
42
|
-
</samlp:StatusCode>
|
43
|
-
</samlp:Status>
|
44
|
-
</samlp:LogoutResponse>"
|
45
|
-
end
|
46
|
-
|
47
|
-
def unsuccessful_logout_response_with_message_document(opts = {})
|
48
|
-
opts = default_logout_response_opts.merge(opts)
|
49
|
-
|
50
|
-
"<samlp:LogoutResponse
|
51
|
-
xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\"
|
52
|
-
ID=\"#{random_id}\" Version=\"2.0\"
|
53
|
-
IssueInstant=\"#{opts[:issue_instant]}\"
|
54
|
-
Destination=\"#{opts[:settings].single_logout_service_url}\"
|
55
|
-
InResponseTo=\"#{opts[:uuid]}\">
|
56
|
-
<saml:Issuer xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\">#{opts[:settings].issuer}</saml:Issuer>
|
57
|
-
<samlp:Status xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\">
|
58
|
-
<samlp:StatusCode xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\"
|
59
|
-
Value=\"urn:oasis:names:tc:SAML:2.0:status:Requester\">
|
60
|
-
</samlp:StatusCode>
|
61
|
-
<samlp:StatusMessage>Logoutrequest expired</samlp:StatusMessage>
|
62
|
-
</samlp:Status>
|
63
|
-
</samlp:LogoutResponse>"
|
64
|
-
end
|
65
|
-
|
66
|
-
def invalid_xml_logout_response_document
|
67
|
-
"<samlp:SomethingAwful
|
68
|
-
xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\"
|
69
|
-
ID=\"#{random_id}\" Version=\"2.0\">
|
70
|
-
</samlp:SomethingAwful>"
|
71
|
-
end
|
72
|
-
|
73
|
-
def settings
|
74
|
-
@settings ||= OneLogin::RubySaml::Settings.new(
|
75
|
-
{
|
76
|
-
:assertion_consumer_service_url => "http://app.muda.no/sso/consume",
|
77
|
-
:single_logout_service_url => "http://app.muda.no/sso/consume_logout",
|
78
|
-
:issuer => "http://app.muda.no",
|
79
|
-
: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",
|
82
|
-
:idp_cert_fingerprint => "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
|
83
|
-
:name_identifier_format => "urn:oasis:names:tc:SAML:2.0:nameid-format:transient",
|
84
|
-
}
|
85
|
-
)
|
86
|
-
end
|
data/test/logoutrequest_test.rb
DELETED
@@ -1,260 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
|
2
|
-
|
3
|
-
require 'onelogin/ruby-saml/logoutrequest'
|
4
|
-
|
5
|
-
class RequestTest < Minitest::Test
|
6
|
-
|
7
|
-
describe "Logoutrequest" do
|
8
|
-
let(:settings) { OneLogin::RubySaml::Settings.new }
|
9
|
-
|
10
|
-
before do
|
11
|
-
settings.idp_slo_target_url = "http://unauth.com/logout"
|
12
|
-
settings.name_identifier_value = "f00f00"
|
13
|
-
end
|
14
|
-
|
15
|
-
it "create the deflated SAMLRequest URL parameter" do
|
16
|
-
unauth_url = OneLogin::RubySaml::Logoutrequest.new.create(settings)
|
17
|
-
assert_match /^http:\/\/unauth\.com\/logout\?SAMLRequest=/, unauth_url
|
18
|
-
|
19
|
-
inflated = decode_saml_request_payload(unauth_url)
|
20
|
-
assert_match /^<samlp:LogoutRequest/, inflated
|
21
|
-
end
|
22
|
-
|
23
|
-
it "support additional params" do
|
24
|
-
unauth_url = OneLogin::RubySaml::Logoutrequest.new.create(settings, { :hello => nil })
|
25
|
-
assert_match /&hello=$/, unauth_url
|
26
|
-
|
27
|
-
unauth_url = OneLogin::RubySaml::Logoutrequest.new.create(settings, { :foo => "bar" })
|
28
|
-
assert_match /&foo=bar$/, unauth_url
|
29
|
-
end
|
30
|
-
|
31
|
-
it "RelayState cases" do
|
32
|
-
unauth_url = OneLogin::RubySaml::Logoutrequest.new.create(settings, { :RelayState => nil })
|
33
|
-
assert !unauth_url.include?('RelayState')
|
34
|
-
|
35
|
-
unauth_url = OneLogin::RubySaml::Logoutrequest.new.create(settings, { :RelayState => "http://example.com" })
|
36
|
-
assert unauth_url.include?('&RelayState=http%3A%2F%2Fexample.com')
|
37
|
-
|
38
|
-
unauth_url = OneLogin::RubySaml::Logoutrequest.new.create(settings, { 'RelayState' => nil })
|
39
|
-
assert !unauth_url.include?('RelayState')
|
40
|
-
|
41
|
-
unauth_url = OneLogin::RubySaml::Logoutrequest.new.create(settings, { 'RelayState' => "http://example.com" })
|
42
|
-
assert unauth_url.include?('&RelayState=http%3A%2F%2Fexample.com')
|
43
|
-
end
|
44
|
-
|
45
|
-
it "set sessionindex" do
|
46
|
-
settings.idp_slo_target_url = "http://example.com"
|
47
|
-
sessionidx = OneLogin::RubySaml::Utils.uuid
|
48
|
-
settings.sessionindex = sessionidx
|
49
|
-
|
50
|
-
unauth_url = OneLogin::RubySaml::Logoutrequest.new.create(settings, { :nameid => "there" })
|
51
|
-
inflated = decode_saml_request_payload(unauth_url)
|
52
|
-
|
53
|
-
assert_match /<samlp:SessionIndex/, inflated
|
54
|
-
assert_match %r(#{sessionidx}</samlp:SessionIndex>), inflated
|
55
|
-
end
|
56
|
-
|
57
|
-
it "set name_identifier_value" do
|
58
|
-
settings.name_identifier_format = "transient"
|
59
|
-
name_identifier_value = "abc123"
|
60
|
-
settings.name_identifier_value = name_identifier_value
|
61
|
-
|
62
|
-
unauth_url = OneLogin::RubySaml::Logoutrequest.new.create(settings, { :nameid => "there" })
|
63
|
-
inflated = decode_saml_request_payload(unauth_url)
|
64
|
-
|
65
|
-
assert_match /<saml:NameID/, inflated
|
66
|
-
assert_match %r(#{name_identifier_value}</saml:NameID>), inflated
|
67
|
-
end
|
68
|
-
|
69
|
-
describe "when the target url doesn't contain a query string" do
|
70
|
-
it "create the SAMLRequest parameter correctly" do
|
71
|
-
unauth_url = OneLogin::RubySaml::Logoutrequest.new.create(settings)
|
72
|
-
assert_match /^http:\/\/unauth.com\/logout\?SAMLRequest/, unauth_url
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe "when the target url contains a query string" do
|
77
|
-
it "create the SAMLRequest parameter correctly" do
|
78
|
-
settings.idp_slo_target_url = "http://example.com?field=value"
|
79
|
-
|
80
|
-
unauth_url = OneLogin::RubySaml::Logoutrequest.new.create(settings)
|
81
|
-
assert_match /^http:\/\/example.com\?field=value&SAMLRequest/, unauth_url
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe "consumation of logout may need to track the transaction" do
|
86
|
-
it "have access to the request uuid" do
|
87
|
-
settings.idp_slo_target_url = "http://example.com?field=value"
|
88
|
-
|
89
|
-
unauth_req = OneLogin::RubySaml::Logoutrequest.new
|
90
|
-
unauth_url = unauth_req.create(settings)
|
91
|
-
|
92
|
-
inflated = decode_saml_request_payload(unauth_url)
|
93
|
-
assert_match %r[ID='#{unauth_req.uuid}'], inflated
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "when the settings indicate to sign (embedded) logout request" do
|
98
|
-
|
99
|
-
before do
|
100
|
-
# sign the logout request
|
101
|
-
settings.security[:logout_requests_signed] = true
|
102
|
-
settings.security[:embed_sign] = true
|
103
|
-
settings.certificate = ruby_saml_cert_text
|
104
|
-
settings.private_key = ruby_saml_key_text
|
105
|
-
end
|
106
|
-
|
107
|
-
it "doesn't sign through create_xml_document" do
|
108
|
-
unauth_req = OneLogin::RubySaml::Logoutrequest.new
|
109
|
-
inflated = unauth_req.create_xml_document(settings).to_s
|
110
|
-
|
111
|
-
refute_match %r[<ds:SignatureValue>([a-zA-Z0-9/+=]+)</ds:SignatureValue>], inflated
|
112
|
-
refute_match %r[<ds:SignatureMethod Algorithm='http://www.w3.org/2000/09/xmldsig#rsa-sha1'/>], inflated
|
113
|
-
refute_match %r[<ds:DigestMethod Algorithm='http://www.w3.org/2000/09/xmldsig#sha1'/>], inflated
|
114
|
-
end
|
115
|
-
|
116
|
-
it "sign unsigned request" do
|
117
|
-
unauth_req = OneLogin::RubySaml::Logoutrequest.new
|
118
|
-
unauth_req_doc = unauth_req.create_xml_document(settings)
|
119
|
-
inflated = unauth_req_doc.to_s
|
120
|
-
|
121
|
-
refute_match %r[<ds:SignatureValue>([a-zA-Z0-9/+=]+)</ds:SignatureValue>], inflated
|
122
|
-
refute_match %r[<ds:SignatureMethod Algorithm='http://www.w3.org/2000/09/xmldsig#rsa-sha1'/>], inflated
|
123
|
-
refute_match %r[<ds:DigestMethod Algorithm='http://www.w3.org/2000/09/xmldsig#sha1'/>], inflated
|
124
|
-
|
125
|
-
inflated = unauth_req.sign_document(unauth_req_doc, settings).to_s
|
126
|
-
|
127
|
-
assert_match %r[<ds:SignatureValue>([a-zA-Z0-9/+=]+)</ds:SignatureValue>], inflated
|
128
|
-
assert_match %r[<ds:SignatureMethod Algorithm='http://www.w3.org/2000/09/xmldsig#rsa-sha1'/>], inflated
|
129
|
-
assert_match %r[<ds:DigestMethod Algorithm='http://www.w3.org/2000/09/xmldsig#sha1'/>], inflated
|
130
|
-
end
|
131
|
-
|
132
|
-
it "signs through create_logout_request_xml_doc" do
|
133
|
-
unauth_req = OneLogin::RubySaml::Logoutrequest.new
|
134
|
-
inflated = unauth_req.create_logout_request_xml_doc(settings).to_s
|
135
|
-
|
136
|
-
assert_match %r[<ds:SignatureValue>([a-zA-Z0-9/+=]+)</ds:SignatureValue>], inflated
|
137
|
-
assert_match %r[<ds:SignatureMethod Algorithm='http://www.w3.org/2000/09/xmldsig#rsa-sha1'/>], inflated
|
138
|
-
assert_match %r[<ds:DigestMethod Algorithm='http://www.w3.org/2000/09/xmldsig#sha1'/>], inflated
|
139
|
-
end
|
140
|
-
|
141
|
-
it "created a signed logout request" do
|
142
|
-
settings.compress_request = true
|
143
|
-
|
144
|
-
unauth_req = OneLogin::RubySaml::Logoutrequest.new
|
145
|
-
unauth_url = unauth_req.create(settings)
|
146
|
-
|
147
|
-
inflated = decode_saml_request_payload(unauth_url)
|
148
|
-
assert_match %r[<ds:SignatureValue>([a-zA-Z0-9/+=]+)</ds:SignatureValue>], inflated
|
149
|
-
assert_match %r[<ds:SignatureMethod Algorithm='http://www.w3.org/2000/09/xmldsig#rsa-sha1'/>], inflated
|
150
|
-
assert_match %r[<ds:DigestMethod Algorithm='http://www.w3.org/2000/09/xmldsig#sha1'/>], inflated
|
151
|
-
end
|
152
|
-
|
153
|
-
it "create a signed logout request with 256 digest and signature method" do
|
154
|
-
settings.compress_request = false
|
155
|
-
settings.security[:signature_method] = XMLSecurity::Document::RSA_SHA256
|
156
|
-
settings.security[:digest_method] = XMLSecurity::Document::SHA256
|
157
|
-
|
158
|
-
params = OneLogin::RubySaml::Logoutrequest.new.create_params(settings)
|
159
|
-
request_xml = Base64.decode64(params["SAMLRequest"])
|
160
|
-
|
161
|
-
assert_match %r[<ds:SignatureValue>([a-zA-Z0-9/+=]+)</ds:SignatureValue>], request_xml
|
162
|
-
assert_match %r[<ds:SignatureMethod Algorithm='http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'/>], request_xml
|
163
|
-
assert_match %r[<ds:DigestMethod Algorithm='http://www.w3.org/2001/04/xmlenc#sha256'/>], request_xml
|
164
|
-
end
|
165
|
-
|
166
|
-
it "create a signed logout request with 512 digest and signature method RSA_SHA384" do
|
167
|
-
settings.compress_request = false
|
168
|
-
settings.security[:signature_method] = XMLSecurity::Document::RSA_SHA384
|
169
|
-
settings.security[:digest_method] = XMLSecurity::Document::SHA512
|
170
|
-
|
171
|
-
params = OneLogin::RubySaml::Logoutrequest.new.create_params(settings)
|
172
|
-
request_xml = Base64.decode64(params["SAMLRequest"])
|
173
|
-
|
174
|
-
assert_match %r[<ds:SignatureValue>([a-zA-Z0-9/+=]+)</ds:SignatureValue>], request_xml
|
175
|
-
assert_match %r[<ds:SignatureMethod Algorithm='http://www.w3.org/2001/04/xmldsig-more#rsa-sha384'/>], request_xml
|
176
|
-
assert_match %r[<ds:DigestMethod Algorithm='http://www.w3.org/2001/04/xmlenc#sha512'/>], request_xml
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
describe "#create_params when the settings indicate to sign the logout request" do
|
181
|
-
|
182
|
-
let(:cert) { OpenSSL::X509::Certificate.new(ruby_saml_cert_text) }
|
183
|
-
|
184
|
-
before do
|
185
|
-
# sign the logout request
|
186
|
-
settings.security[:logout_requests_signed] = true
|
187
|
-
settings.security[:embed_sign] = false
|
188
|
-
settings.certificate = ruby_saml_cert_text
|
189
|
-
settings.private_key = ruby_saml_key_text
|
190
|
-
end
|
191
|
-
|
192
|
-
it "create a signature parameter with RSA_SHA1 / SHA1 and validate it" do
|
193
|
-
settings.security[:signature_method] = XMLSecurity::Document::RSA_SHA1
|
194
|
-
|
195
|
-
params = OneLogin::RubySaml::Logoutrequest.new.create_params(settings, :RelayState => 'http://example.com')
|
196
|
-
assert params['SAMLRequest']
|
197
|
-
assert params[:RelayState]
|
198
|
-
assert params['Signature']
|
199
|
-
assert_equal params['SigAlg'], XMLSecurity::Document::RSA_SHA1
|
200
|
-
|
201
|
-
query_string = "SAMLRequest=#{CGI.escape(params['SAMLRequest'])}"
|
202
|
-
query_string << "&RelayState=#{CGI.escape(params[:RelayState])}"
|
203
|
-
query_string << "&SigAlg=#{CGI.escape(params['SigAlg'])}"
|
204
|
-
|
205
|
-
signature_algorithm = XMLSecurity::BaseDocument.new.algorithm(params['SigAlg'])
|
206
|
-
assert_equal signature_algorithm, OpenSSL::Digest::SHA1
|
207
|
-
assert cert.public_key.verify(signature_algorithm.new, Base64.decode64(params['Signature']), query_string)
|
208
|
-
end
|
209
|
-
|
210
|
-
it "create a signature parameter with RSA_SHA256 / SHA256 and validate it" do
|
211
|
-
settings.security[:signature_method] = XMLSecurity::Document::RSA_SHA256
|
212
|
-
|
213
|
-
params = OneLogin::RubySaml::Logoutrequest.new.create_params(settings, :RelayState => 'http://example.com')
|
214
|
-
assert params['Signature']
|
215
|
-
assert_equal params['SigAlg'], XMLSecurity::Document::RSA_SHA256
|
216
|
-
|
217
|
-
query_string = "SAMLRequest=#{CGI.escape(params['SAMLRequest'])}"
|
218
|
-
query_string << "&RelayState=#{CGI.escape(params[:RelayState])}"
|
219
|
-
query_string << "&SigAlg=#{CGI.escape(params['SigAlg'])}"
|
220
|
-
|
221
|
-
signature_algorithm = XMLSecurity::BaseDocument.new.algorithm(params['SigAlg'])
|
222
|
-
assert_equal signature_algorithm, OpenSSL::Digest::SHA256
|
223
|
-
assert cert.public_key.verify(signature_algorithm.new, Base64.decode64(params['Signature']), query_string)
|
224
|
-
end
|
225
|
-
|
226
|
-
it "create a signature parameter with RSA_SHA384 / SHA384 and validate it" do
|
227
|
-
settings.security[:signature_method] = XMLSecurity::Document::RSA_SHA384
|
228
|
-
|
229
|
-
params = OneLogin::RubySaml::Logoutrequest.new.create_params(settings, :RelayState => 'http://example.com')
|
230
|
-
assert params['Signature']
|
231
|
-
assert_equal params['SigAlg'], XMLSecurity::Document::RSA_SHA384
|
232
|
-
|
233
|
-
query_string = "SAMLRequest=#{CGI.escape(params['SAMLRequest'])}"
|
234
|
-
query_string << "&RelayState=#{CGI.escape(params[:RelayState])}"
|
235
|
-
query_string << "&SigAlg=#{CGI.escape(params['SigAlg'])}"
|
236
|
-
|
237
|
-
signature_algorithm = XMLSecurity::BaseDocument.new.algorithm(params['SigAlg'])
|
238
|
-
assert_equal signature_algorithm, OpenSSL::Digest::SHA384
|
239
|
-
assert cert.public_key.verify(signature_algorithm.new, Base64.decode64(params['Signature']), query_string)
|
240
|
-
end
|
241
|
-
|
242
|
-
it "create a signature parameter with RSA_SHA512 / SHA512 and validate it" do
|
243
|
-
settings.security[:signature_method] = XMLSecurity::Document::RSA_SHA512
|
244
|
-
|
245
|
-
params = OneLogin::RubySaml::Logoutrequest.new.create_params(settings, :RelayState => 'http://example.com')
|
246
|
-
assert params['Signature']
|
247
|
-
assert_equal params['SigAlg'], XMLSecurity::Document::RSA_SHA512
|
248
|
-
|
249
|
-
query_string = "SAMLRequest=#{CGI.escape(params['SAMLRequest'])}"
|
250
|
-
query_string << "&RelayState=#{CGI.escape(params[:RelayState])}"
|
251
|
-
query_string << "&SigAlg=#{CGI.escape(params['SigAlg'])}"
|
252
|
-
|
253
|
-
signature_algorithm = XMLSecurity::BaseDocument.new.algorithm(params['SigAlg'])
|
254
|
-
assert_equal signature_algorithm, OpenSSL::Digest::SHA512
|
255
|
-
assert cert.public_key.verify(signature_algorithm.new, Base64.decode64(params['Signature']), query_string)
|
256
|
-
end
|
257
|
-
|
258
|
-
end
|
259
|
-
end
|
260
|
-
end
|