ruby-saml 1.7.2 → 1.12.2

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.

Files changed (154) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +37 -15
  3. data/README.md +127 -25
  4. data/changelog.md +61 -0
  5. data/lib/onelogin/ruby-saml/attribute_service.rb +1 -1
  6. data/lib/onelogin/ruby-saml/attributes.rb +24 -1
  7. data/lib/onelogin/ruby-saml/authrequest.rb +29 -6
  8. data/lib/onelogin/ruby-saml/idp_metadata_parser.rb +239 -169
  9. data/lib/onelogin/ruby-saml/logging.rb +4 -1
  10. data/lib/onelogin/ruby-saml/logoutrequest.rb +27 -7
  11. data/lib/onelogin/ruby-saml/logoutresponse.rb +32 -16
  12. data/lib/onelogin/ruby-saml/metadata.rb +11 -3
  13. data/lib/onelogin/ruby-saml/response.rb +91 -30
  14. data/lib/onelogin/ruby-saml/saml_message.rb +15 -5
  15. data/lib/onelogin/ruby-saml/setting_error.rb +6 -0
  16. data/lib/onelogin/ruby-saml/settings.rb +82 -9
  17. data/lib/onelogin/ruby-saml/slo_logoutrequest.rb +26 -7
  18. data/lib/onelogin/ruby-saml/slo_logoutresponse.rb +46 -18
  19. data/lib/onelogin/ruby-saml/utils.rb +87 -10
  20. data/lib/onelogin/ruby-saml/version.rb +1 -1
  21. data/lib/xml_security.rb +39 -12
  22. data/ruby-saml.gemspec +16 -8
  23. metadata +40 -274
  24. data/test/certificates/certificate1 +0 -12
  25. data/test/certificates/certificate_without_head_foot +0 -1
  26. data/test/certificates/formatted_certificate +0 -14
  27. data/test/certificates/formatted_chained_certificate +0 -42
  28. data/test/certificates/formatted_private_key +0 -12
  29. data/test/certificates/formatted_rsa_private_key +0 -12
  30. data/test/certificates/invalid_certificate1 +0 -1
  31. data/test/certificates/invalid_certificate2 +0 -1
  32. data/test/certificates/invalid_certificate3 +0 -12
  33. data/test/certificates/invalid_chained_certificate1 +0 -1
  34. data/test/certificates/invalid_private_key1 +0 -1
  35. data/test/certificates/invalid_private_key2 +0 -1
  36. data/test/certificates/invalid_private_key3 +0 -10
  37. data/test/certificates/invalid_rsa_private_key1 +0 -1
  38. data/test/certificates/invalid_rsa_private_key2 +0 -1
  39. data/test/certificates/invalid_rsa_private_key3 +0 -10
  40. data/test/certificates/ruby-saml-2.crt +0 -15
  41. data/test/certificates/ruby-saml.crt +0 -14
  42. data/test/certificates/ruby-saml.key +0 -15
  43. data/test/idp_metadata_parser_test.rb +0 -568
  44. data/test/logging_test.rb +0 -62
  45. data/test/logout_requests/invalid_slo_request.xml +0 -6
  46. data/test/logout_requests/slo_request.xml +0 -4
  47. data/test/logout_requests/slo_request.xml.base64 +0 -1
  48. data/test/logout_requests/slo_request_deflated.xml.base64 +0 -1
  49. data/test/logout_requests/slo_request_with_name_id_format.xml +0 -4
  50. data/test/logout_requests/slo_request_with_session_index.xml +0 -5
  51. data/test/logout_responses/logoutresponse_fixtures.rb +0 -67
  52. data/test/logoutrequest_test.rb +0 -212
  53. data/test/logoutresponse_test.rb +0 -402
  54. data/test/metadata/idp_descriptor.xml +0 -26
  55. data/test/metadata/idp_descriptor_2.xml +0 -56
  56. data/test/metadata/idp_descriptor_3.xml +0 -14
  57. data/test/metadata/idp_metadata_different_sign_and_encrypt_cert.xml +0 -72
  58. data/test/metadata/idp_metadata_multi_certs.xml +0 -75
  59. data/test/metadata/idp_metadata_multi_signing_certs.xml +0 -52
  60. data/test/metadata/idp_metadata_same_sign_and_encrypt_cert.xml +0 -71
  61. data/test/metadata/idp_multiple_descriptors.xml +0 -53
  62. data/test/metadata/no_idp_descriptor.xml +0 -21
  63. data/test/metadata_test.rb +0 -331
  64. data/test/request_test.rb +0 -296
  65. data/test/response_test.rb +0 -1535
  66. data/test/responses/adfs_response_sha1.xml +0 -46
  67. data/test/responses/adfs_response_sha256.xml +0 -46
  68. data/test/responses/adfs_response_sha384.xml +0 -46
  69. data/test/responses/adfs_response_sha512.xml +0 -46
  70. data/test/responses/adfs_response_xmlns.xml +0 -45
  71. data/test/responses/attackxee.xml +0 -13
  72. data/test/responses/invalids/duplicated_attributes.xml.base64 +0 -1
  73. data/test/responses/invalids/empty_destination.xml.base64 +0 -1
  74. data/test/responses/invalids/empty_nameid.xml.base64 +0 -1
  75. data/test/responses/invalids/encrypted_new_attack.xml.base64 +0 -1
  76. data/test/responses/invalids/invalid_audience.xml.base64 +0 -1
  77. data/test/responses/invalids/invalid_issuer_assertion.xml.base64 +0 -1
  78. data/test/responses/invalids/invalid_issuer_message.xml.base64 +0 -1
  79. data/test/responses/invalids/invalid_signature_position.xml.base64 +0 -1
  80. data/test/responses/invalids/invalid_subjectconfirmation_inresponse.xml.base64 +0 -1
  81. data/test/responses/invalids/invalid_subjectconfirmation_nb.xml.base64 +0 -1
  82. data/test/responses/invalids/invalid_subjectconfirmation_noa.xml.base64 +0 -1
  83. data/test/responses/invalids/invalid_subjectconfirmation_recipient.xml.base64 +0 -1
  84. data/test/responses/invalids/multiple_assertions.xml.base64 +0 -2
  85. data/test/responses/invalids/multiple_signed.xml.base64 +0 -1
  86. data/test/responses/invalids/no_authnstatement.xml.base64 +0 -1
  87. data/test/responses/invalids/no_conditions.xml.base64 +0 -1
  88. data/test/responses/invalids/no_id.xml.base64 +0 -1
  89. data/test/responses/invalids/no_issuer_assertion.xml.base64 +0 -1
  90. data/test/responses/invalids/no_issuer_response.xml.base64 +0 -1
  91. data/test/responses/invalids/no_nameid.xml.base64 +0 -1
  92. data/test/responses/invalids/no_saml2.xml.base64 +0 -1
  93. data/test/responses/invalids/no_signature.xml.base64 +0 -1
  94. data/test/responses/invalids/no_status.xml.base64 +0 -1
  95. data/test/responses/invalids/no_status_code.xml.base64 +0 -1
  96. data/test/responses/invalids/no_subjectconfirmation_data.xml.base64 +0 -1
  97. data/test/responses/invalids/no_subjectconfirmation_method.xml.base64 +0 -1
  98. data/test/responses/invalids/response_invalid_signed_element.xml.base64 +0 -1
  99. data/test/responses/invalids/response_with_concealed_signed_assertion.xml +0 -51
  100. data/test/responses/invalids/response_with_doubled_signed_assertion.xml +0 -49
  101. data/test/responses/invalids/signature_wrapping_attack.xml.base64 +0 -1
  102. data/test/responses/invalids/status_code_responder.xml.base64 +0 -1
  103. data/test/responses/invalids/status_code_responer_and_msg.xml.base64 +0 -1
  104. data/test/responses/invalids/wrong_spnamequalifier.xml.base64 +0 -1
  105. data/test/responses/no_signature_ns.xml +0 -48
  106. data/test/responses/open_saml_response.xml +0 -56
  107. data/test/responses/response_assertion_wrapped.xml.base64 +0 -93
  108. data/test/responses/response_audience_self_closed_tag.xml.base64 +0 -1
  109. data/test/responses/response_double_status_code.xml.base64 +0 -1
  110. data/test/responses/response_encrypted_attrs.xml.base64 +0 -1
  111. data/test/responses/response_encrypted_nameid.xml.base64 +0 -1
  112. data/test/responses/response_eval.xml +0 -7
  113. data/test/responses/response_no_cert_and_encrypted_attrs.xml +0 -29
  114. data/test/responses/response_node_text_attack.xml.base64 +0 -1
  115. data/test/responses/response_unsigned_xml_base64 +0 -1
  116. data/test/responses/response_with_ampersands.xml +0 -139
  117. data/test/responses/response_with_ampersands.xml.base64 +0 -93
  118. data/test/responses/response_with_ds_namespace_at_the_root.xml.base64 +0 -1
  119. data/test/responses/response_with_multiple_attribute_statements.xml +0 -72
  120. data/test/responses/response_with_multiple_attribute_values.xml +0 -67
  121. data/test/responses/response_with_retrieval_method.xml +0 -26
  122. data/test/responses/response_with_saml2_namespace.xml.base64 +0 -102
  123. data/test/responses/response_with_signed_assertion.xml.base64 +0 -66
  124. data/test/responses/response_with_signed_assertion_2.xml.base64 +0 -1
  125. data/test/responses/response_with_signed_assertion_3.xml +0 -30
  126. data/test/responses/response_with_signed_message_and_assertion.xml +0 -34
  127. data/test/responses/response_with_undefined_recipient.xml.base64 +0 -1
  128. data/test/responses/response_without_attributes.xml.base64 +0 -79
  129. data/test/responses/response_without_reference_uri.xml.base64 +0 -1
  130. data/test/responses/response_wrapped.xml.base64 +0 -150
  131. data/test/responses/signed_message_encrypted_signed_assertion.xml.base64 +0 -1
  132. data/test/responses/signed_message_encrypted_unsigned_assertion.xml.base64 +0 -1
  133. data/test/responses/signed_nameid_in_atts.xml +0 -47
  134. data/test/responses/signed_unqual_nameid_in_atts.xml +0 -47
  135. data/test/responses/simple_saml_php.xml +0 -71
  136. data/test/responses/starfield_response.xml.base64 +0 -1
  137. data/test/responses/test_sign.xml +0 -43
  138. data/test/responses/unsigned_encrypted_adfs.xml +0 -23
  139. data/test/responses/unsigned_message_aes128_encrypted_signed_assertion.xml.base64 +0 -1
  140. data/test/responses/unsigned_message_aes192_encrypted_signed_assertion.xml.base64 +0 -1
  141. data/test/responses/unsigned_message_aes256_encrypted_signed_assertion.xml.base64 +0 -1
  142. data/test/responses/unsigned_message_des192_encrypted_signed_assertion.xml.base64 +0 -1
  143. data/test/responses/unsigned_message_encrypted_assertion_without_saml_namespace.xml.base64 +0 -1
  144. data/test/responses/unsigned_message_encrypted_signed_assertion.xml.base64 +0 -1
  145. data/test/responses/unsigned_message_encrypted_unsigned_assertion.xml.base64 +0 -1
  146. data/test/responses/valid_response.xml.base64 +0 -1
  147. data/test/responses/valid_response_without_x509certificate.xml.base64 +0 -1
  148. data/test/saml_message_test.rb +0 -56
  149. data/test/settings_test.rb +0 -301
  150. data/test/slo_logoutrequest_test.rb +0 -448
  151. data/test/slo_logoutresponse_test.rb +0 -185
  152. data/test/test_helper.rb +0 -323
  153. data/test/utils_test.rb +0 -254
  154. data/test/xml_security_test.rb +0 -421
@@ -1,568 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
2
-
3
- require 'onelogin/ruby-saml/idp_metadata_parser'
4
-
5
- class IdpMetadataParserTest < Minitest::Test
6
- class MockSuccessResponse < Net::HTTPSuccess
7
- # override parent's initialize
8
- def initialize; end
9
-
10
- attr_accessor :body
11
- end
12
-
13
- class MockFailureResponse < Net::HTTPNotFound
14
- # override parent's initialize
15
- def initialize; end
16
-
17
- attr_accessor :body
18
- end
19
-
20
- describe "parsing an IdP descriptor file" do
21
- it "extract settings details from xml" do
22
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
23
-
24
- settings = idp_metadata_parser.parse(idp_metadata_descriptor)
25
-
26
- 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
28
- 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
30
- assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", settings.name_identifier_format
31
- assert_equal ["AuthToken", "SSOStartPage"], settings.idp_attribute_names
32
- end
33
-
34
- it "extract certificate from md:KeyDescriptor[@use='signing']" do
35
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
36
- idp_metadata = idp_metadata_descriptor
37
- settings = idp_metadata_parser.parse(idp_metadata)
38
- 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
39
- end
40
-
41
- it "extract certificate from md:KeyDescriptor[@use='encryption']" do
42
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
43
- idp_metadata = idp_metadata_descriptor
44
- idp_metadata = idp_metadata.sub(/<md:KeyDescriptor use="signing">(.*?)<\/md:KeyDescriptor>/m, "")
45
- settings = idp_metadata_parser.parse(idp_metadata)
46
- 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
47
- end
48
-
49
- it "extract certificate from md:KeyDescriptor" do
50
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
51
- idp_metadata = idp_metadata_descriptor
52
- idp_metadata = idp_metadata.sub(/<md:KeyDescriptor use="signing">(.*?)<\/md:KeyDescriptor>/m, "")
53
- idp_metadata = idp_metadata.sub('<md:KeyDescriptor use="encryption">', '<md:KeyDescriptor>')
54
- settings = idp_metadata_parser.parse(idp_metadata)
55
- 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
56
- end
57
-
58
- it "extract SSO endpoint with no specific binding, it takes the first" do
59
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
60
- idp_metadata = idp_metadata_descriptor3
61
- settings = idp_metadata_parser.parse(idp_metadata)
62
- assert_equal "https://idp.example.com/idp/profile/Shibboleth/SSO", settings.idp_sso_target_url
63
- end
64
-
65
- it "extract SSO endpoint with specific binding" do
66
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
67
- idp_metadata = idp_metadata_descriptor3
68
- options = {}
69
- options[:sso_binding] = ['urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST']
70
- settings = idp_metadata_parser.parse(idp_metadata, options)
71
- assert_equal "https://idp.example.com/idp/profile/SAML2/POST/SSO", settings.idp_sso_target_url
72
-
73
- options[:sso_binding] = ['urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect']
74
- settings = idp_metadata_parser.parse(idp_metadata, options)
75
- assert_equal "https://idp.example.com/idp/profile/SAML2/Redirect/SSO", settings.idp_sso_target_url
76
-
77
- options[:sso_binding] = ['invalid_binding', 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect']
78
- settings = idp_metadata_parser.parse(idp_metadata, options)
79
- assert_equal "https://idp.example.com/idp/profile/SAML2/Redirect/SSO", settings.idp_sso_target_url
80
- end
81
-
82
- it "uses settings options as hash for overrides" do
83
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
84
- idp_metadata = idp_metadata_descriptor
85
- settings = idp_metadata_parser.parse(idp_metadata, {
86
- :settings => {
87
- :security => {
88
- :digest_method => XMLSecurity::Document::SHA256,
89
- :signature_method => XMLSecurity::Document::RSA_SHA256
90
- }
91
- }
92
- })
93
- 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
94
- assert_equal XMLSecurity::Document::SHA256, settings.security[:digest_method]
95
- assert_equal XMLSecurity::Document::RSA_SHA256, settings.security[:signature_method]
96
- end
97
-
98
- it "merges results into given settings object" do
99
- settings = OneLogin::RubySaml::Settings.new(:security => {
100
- :digest_method => XMLSecurity::Document::SHA256,
101
- :signature_method => XMLSecurity::Document::RSA_SHA256
102
- })
103
-
104
- OneLogin::RubySaml::IdpMetadataParser.new.parse(idp_metadata_descriptor, :settings => settings)
105
-
106
- 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
107
- assert_equal XMLSecurity::Document::SHA256, settings.security[:digest_method]
108
- assert_equal XMLSecurity::Document::RSA_SHA256, settings.security[:signature_method]
109
- end
110
- end
111
-
112
- describe "parsing an IdP descriptor file into an Hash" do
113
- it "extract settings details from xml" do
114
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
115
-
116
- metadata = idp_metadata_parser.parse_to_hash(idp_metadata_descriptor)
117
-
118
- assert_equal "https://hello.example.com/access/saml/idp.xml", metadata[:idp_entity_id]
119
- assert_equal "https://hello.example.com/access/saml/login", metadata[:idp_sso_target_url]
120
- 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]
121
- assert_equal "https://hello.example.com/access/saml/logout", metadata[:idp_slo_target_url]
122
- assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", metadata[:name_identifier_format]
123
- assert_equal ["AuthToken", "SSOStartPage"], metadata[:idp_attribute_names]
124
- end
125
-
126
- it "extract certificate from md:KeyDescriptor[@use='signing']" do
127
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
128
- idp_metadata = idp_metadata_descriptor
129
- metadata = idp_metadata_parser.parse_to_hash(idp_metadata)
130
- 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]
131
- end
132
-
133
- it "extract certificate from md:KeyDescriptor[@use='encryption']" do
134
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
135
- idp_metadata = idp_metadata_descriptor
136
- idp_metadata = idp_metadata.sub(/<md:KeyDescriptor use="signing">(.*?)<\/md:KeyDescriptor>/m, "")
137
- parsed_metadata = idp_metadata_parser.parse_to_hash(idp_metadata)
138
- 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]
139
- end
140
-
141
- it "extract certificate from md:KeyDescriptor" do
142
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
143
- idp_metadata = idp_metadata_descriptor
144
- idp_metadata = idp_metadata.sub(/<md:KeyDescriptor use="signing">(.*?)<\/md:KeyDescriptor>/m, "")
145
- idp_metadata = idp_metadata.sub('<md:KeyDescriptor use="encryption">', '<md:KeyDescriptor>')
146
- parsed_metadata = idp_metadata_parser.parse_to_hash(idp_metadata)
147
- 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]
148
- end
149
-
150
- it "extract SSO endpoint with no specific binding, it takes the first" do
151
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
152
- idp_metadata = idp_metadata_descriptor3
153
- metadata = idp_metadata_parser.parse_to_hash(idp_metadata)
154
- assert_equal "https://idp.example.com/idp/profile/Shibboleth/SSO", metadata[:idp_sso_target_url]
155
- end
156
-
157
- it "extract SSO endpoint with specific binding" do
158
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
159
- idp_metadata = idp_metadata_descriptor3
160
- options = {}
161
- options[:sso_binding] = ['urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST']
162
- parsed_metadata = idp_metadata_parser.parse_to_hash(idp_metadata, options)
163
- assert_equal "https://idp.example.com/idp/profile/SAML2/POST/SSO", parsed_metadata[:idp_sso_target_url]
164
-
165
- options[:sso_binding] = ['urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect']
166
- parsed_metadata = idp_metadata_parser.parse_to_hash(idp_metadata, options)
167
- assert_equal "https://idp.example.com/idp/profile/SAML2/Redirect/SSO", parsed_metadata[:idp_sso_target_url]
168
-
169
- options[:sso_binding] = ['invalid_binding', 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect']
170
- parsed_metadata = idp_metadata_parser.parse_to_hash(idp_metadata, options)
171
- assert_equal "https://idp.example.com/idp/profile/SAML2/Redirect/SSO", parsed_metadata[:idp_sso_target_url]
172
- end
173
-
174
- it "ignores a given :settings hash" do
175
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
176
- idp_metadata = idp_metadata_descriptor
177
- parsed_metadata = idp_metadata_parser.parse_to_hash(idp_metadata, {
178
- :settings => {
179
- :security => {
180
- :digest_method => XMLSecurity::Document::SHA256,
181
- :signature_method => XMLSecurity::Document::RSA_SHA256
182
- }
183
- }
184
- })
185
- 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]
186
- assert_nil parsed_metadata[:security]
187
- end
188
- end
189
-
190
- describe "parsing an IdP descriptor file with multiple signing certs" do
191
- it "extract settings details from xml" do
192
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
193
-
194
- settings = idp_metadata_parser.parse(idp_metadata_descriptor2)
195
-
196
- assert_equal "https://hello.example.com/access/saml/idp.xml", settings.idp_entity_id
197
- assert_equal "https://hello.example.com/access/saml/login", settings.idp_sso_target_url
198
- assert_equal "https://hello.example.com/access/saml/logout", settings.idp_slo_target_url
199
- assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", settings.name_identifier_format
200
- assert_equal ["AuthToken", "SSOStartPage"], settings.idp_attribute_names
201
-
202
- assert_nil settings.idp_cert_fingerprint
203
- assert_nil settings.idp_cert
204
- assert_equal 2, settings.idp_cert_multi.size
205
- assert settings.idp_cert_multi.key?(:signing)
206
- assert_equal 2, settings.idp_cert_multi[:signing].size
207
- assert settings.idp_cert_multi.key?(:encryption)
208
- assert_equal 1, settings.idp_cert_multi[:encryption].size
209
- end
210
- end
211
-
212
- describe "download and parse IdP descriptor file" do
213
- before do
214
- mock_response = MockSuccessResponse.new
215
- mock_response.body = idp_metadata_descriptor
216
- @url = "https://example.com"
217
- uri = URI(@url)
218
-
219
- @http = Net::HTTP.new(uri.host, uri.port)
220
- Net::HTTP.expects(:new).returns(@http)
221
- @http.expects(:request).returns(mock_response)
222
- end
223
-
224
- it "extract settings from remote xml" do
225
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
226
- settings = idp_metadata_parser.parse_remote(@url)
227
-
228
- assert_equal "https://hello.example.com/access/saml/idp.xml", settings.idp_entity_id
229
- assert_equal "https://hello.example.com/access/saml/login", settings.idp_sso_target_url
230
- 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
231
- assert_equal "https://hello.example.com/access/saml/logout", settings.idp_slo_target_url
232
- assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", settings.name_identifier_format
233
- assert_equal ["AuthToken", "SSOStartPage"], settings.idp_attribute_names
234
- assert_equal OpenSSL::SSL::VERIFY_PEER, @http.verify_mode
235
- end
236
-
237
- it "accept self signed certificate if insturcted" do
238
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
239
- idp_metadata_parser.parse_remote(@url, false)
240
-
241
- assert_equal OpenSSL::SSL::VERIFY_NONE, @http.verify_mode
242
- end
243
- end
244
-
245
- describe "download and parse IdP descriptor file into an Hash" do
246
- before do
247
- mock_response = MockSuccessResponse.new
248
- mock_response.body = idp_metadata_descriptor
249
- @url = "https://example.com"
250
- uri = URI(@url)
251
-
252
- @http = Net::HTTP.new(uri.host, uri.port)
253
- Net::HTTP.expects(:new).returns(@http)
254
- @http.expects(:request).returns(mock_response)
255
- end
256
-
257
- it "extract settings from remote xml" do
258
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
259
- parsed_metadata = idp_metadata_parser.parse_remote_to_hash(@url)
260
-
261
- assert_equal "https://hello.example.com/access/saml/idp.xml", parsed_metadata[:idp_entity_id]
262
- assert_equal "https://hello.example.com/access/saml/login", parsed_metadata[:idp_sso_target_url]
263
- 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]
264
- assert_equal "https://hello.example.com/access/saml/logout", parsed_metadata[:idp_slo_target_url]
265
- assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", parsed_metadata[:name_identifier_format]
266
- assert_equal ["AuthToken", "SSOStartPage"], parsed_metadata[:idp_attribute_names]
267
- assert_equal OpenSSL::SSL::VERIFY_PEER, @http.verify_mode
268
- end
269
-
270
- it "accept self signed certificate if insturcted" do
271
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
272
- idp_metadata_parser.parse_remote_to_hash(@url, false)
273
-
274
- assert_equal OpenSSL::SSL::VERIFY_NONE, @http.verify_mode
275
- end
276
- end
277
-
278
- describe "download failure cases" do
279
- it "raises an exception when the url has no scheme" do
280
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
281
-
282
- exception = assert_raises(ArgumentError) do
283
- idp_metadata_parser.parse_remote("blahblah")
284
- end
285
-
286
- assert_equal("url must begin with http or https", exception.message)
287
- end
288
-
289
- it "raises an exception when unable to download metadata" do
290
- mock_response = MockFailureResponse.new
291
- @url = "https://example.com"
292
- uri = URI(@url)
293
-
294
- @http = Net::HTTP.new(uri.host, uri.port)
295
- Net::HTTP.expects(:new).returns(@http)
296
- @http.expects(:request).returns(mock_response)
297
-
298
- idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
299
-
300
- exception = assert_raises(OneLogin::RubySaml::HttpError) do
301
- idp_metadata_parser.parse_remote("https://hello.example.com/access/saml/idp.xml")
302
- end
303
-
304
- assert_match("Failed to fetch idp metadata", exception.message)
305
- end
306
- end
307
-
308
- describe "parsing metadata with many entity descriptors" do
309
- before do
310
- @idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
311
- @idp_metadata = idp_metadata_multiple_descriptors
312
- @settings = @idp_metadata_parser.parse(@idp_metadata)
313
- end
314
-
315
- it "should find first descriptor" do
316
- assert_equal "https://foo.example.com/access/saml/idp.xml", @settings.idp_entity_id
317
- end
318
-
319
- it "should find named descriptor" do
320
- entity_id = "https://bar.example.com/access/saml/idp.xml"
321
- settings = @idp_metadata_parser.parse(
322
- @idp_metadata, :entity_id => entity_id
323
- )
324
- assert_equal entity_id, settings.idp_entity_id
325
- end
326
-
327
- it "should retreive data" do
328
- assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", @settings.name_identifier_format
329
- assert_equal "https://hello.example.com/access/saml/login", @settings.idp_sso_target_url
330
- 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
331
- assert_equal "https://hello.example.com/access/saml/logout", @settings.idp_slo_target_url
332
- assert_equal ["AuthToken", "SSOStartPage"], @settings.idp_attribute_names
333
- end
334
- end
335
-
336
- describe "parsing metadata with no IDPSSODescriptor element" do
337
- before do
338
- @idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
339
- @idp_metadata = no_idp_metadata_descriptor
340
- end
341
-
342
- it "raise due no IDPSSODescriptor element" do
343
- assert_raises(ArgumentError) { @idp_metadata_parser.parse(@idp_metadata) }
344
- end
345
- end
346
-
347
- describe "parsing metadata with IDPSSODescriptor with multiple certs" do
348
- before do
349
- @idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
350
- @idp_metadata = idp_metadata_multiple_certs
351
- @settings = @idp_metadata_parser.parse(@idp_metadata)
352
- end
353
-
354
- it "should return a idp_cert_multi and no idp_cert and no idp_cert_fingerprint" do
355
- assert_nil @settings.idp_cert
356
- assert_nil @settings.idp_cert_fingerprint
357
-
358
- expected_multi_cert = {}
359
- expected_multi_cert[:signing] = ["MIIEZTCCA02gAwIBAgIUPyy/A3bZAZ4m28PzEUUoT7RJhxIwDQYJKoZIhvcNAQEF
360
- BQAwcjELMAkGA1UEBhMCVVMxKzApBgNVBAoMIk9uZUxvZ2luIFRlc3QgKHNnYXJj
361
- aWEtdXMtcHJlcHJvZCkxFTATBgNVBAsMDE9uZUxvZ2luIElkUDEfMB0GA1UEAwwW
362
- T25lTG9naW4gQWNjb3VudCA4OTE0NjAeFw0xNjA4MDQyMjI5MzdaFw0yMTA4MDUy
363
- MjI5MzdaMHIxCzAJBgNVBAYTAlVTMSswKQYDVQQKDCJPbmVMb2dpbiBUZXN0IChz
364
- Z2FyY2lhLXVzLXByZXByb2QpMRUwEwYDVQQLDAxPbmVMb2dpbiBJZFAxHzAdBgNV
365
- BAMMFk9uZUxvZ2luIEFjY291bnQgODkxNDYwggEiMA0GCSqGSIb3DQEBAQUAA4IB
366
- DwAwggEKAoIBAQDN6iqQGcLOCglNO42I2rkzE05UXSiMXT6c8ALThMMiaDw6qqzo
367
- 3sd/tKK+NcNKWLIIC8TozWVyh5ykUiVZps+08xil7VsTU7E+wKu3kvmOsvw2wlRw
368
- tnoKZJwYhnr+RkBa+h1r3ZYUgXm1ZPeHMKj1g18KaWz9+MxYL6BhKqrOzfW/P2xx
369
- VRcFH7/pq+ZsDdgNzD2GD+apzY4MZyZj/N6BpBWJ0GlFsmtBegpbX3LBitJuFkk5
370
- L4/U/jjF1AJa3boBdCUVfATqO5G03H4XS1GySjBIRQXmlUF52rLjg6xCgWJ30/+t
371
- 1X+IHLJeixiQ0vxyh6C4/usCEt94cgD1r8ADAgMBAA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
408
- assert_equal expected_multi_cert, @settings.idp_cert_multi
409
- assert_equal "https://idp.examle.com/saml/metadata", @settings.idp_entity_id
410
- assert_equal "urn:oasis:names:tc:SAML:2.0:nameid-format:transient", @settings.name_identifier_format
411
- assert_equal "https://idp.examle.com/saml/sso", @settings.idp_sso_target_url
412
- assert_equal "https://idp.examle.com/saml/slo", @settings.idp_slo_target_url
413
- end
414
- end
415
-
416
- describe "parsing metadata with IDPSSODescriptor with multiple signing certs" do
417
- before do
418
- @idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
419
- @idp_metadata = idp_metadata_multiple_signing_certs
420
- @settings = @idp_metadata_parser.parse(@idp_metadata)
421
- end
422
-
423
- it "should return a idp_cert_multi and no idp_cert and no idp_cert_fingerprint" do
424
- assert_nil @settings.idp_cert
425
- assert_nil @settings.idp_cert_fingerprint
426
-
427
- expected_multi_cert = {}
428
- expected_multi_cert[:signing] = ["MIIEZTCCA02gAwIBAgIUPyy/A3bZAZ4m28PzEUUoT7RJhxIwDQYJKoZIhvcNAQEF
429
- BQAwcjELMAkGA1UEBhMCVVMxKzApBgNVBAoMIk9uZUxvZ2luIFRlc3QgKHNnYXJj
430
- aWEtdXMtcHJlcHJvZCkxFTATBgNVBAsMDE9uZUxvZ2luIElkUDEfMB0GA1UEAwwW
431
- T25lTG9naW4gQWNjb3VudCA4OTE0NjAeFw0xNjA4MDQyMjI5MzdaFw0yMTA4MDUy
432
- MjI5MzdaMHIxCzAJBgNVBAYTAlVTMSswKQYDVQQKDCJPbmVMb2dpbiBUZXN0IChz
433
- Z2FyY2lhLXVzLXByZXByb2QpMRUwEwYDVQQLDAxPbmVMb2dpbiBJZFAxHzAdBgNV
434
- BAMMFk9uZUxvZ2luIEFjY291bnQgODkxNDYwggEiMA0GCSqGSIb3DQEBAQUAA4IB
435
- DwAwggEKAoIBAQDN6iqQGcLOCglNO42I2rkzE05UXSiMXT6c8ALThMMiaDw6qqzo
436
- 3sd/tKK+NcNKWLIIC8TozWVyh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bb0dBMVVFQ2d3RFVFbFVNUWt3CkJ3WURWUVFMREFBeEdEQVdCZ05WQkFNTUQyeGhkM0psYm1ObGNHbDBMbU52YlRFbE1DTUdDU3FHU0liM0RRRUoKQVF3V2JHRjNjbVZ1WTJVdWNHbDBRR2R0WVdsc0xtTnZiWUlCQVRBTkJna3Foa2lHOXcwQkFRc0ZBQU9CZ1FDRQpUQWVKVERTQVc2ejFVRlRWN1FyZWg0VUxGT1JhajkrZUN1RjNLV0RIYyswSVFDajlyZG5ERzRRL3dmNy9yYVEwCkpuUFFDU0NkclBMSmV5b1BIN1FhVHdvYUY3ZHpWdzRMQ3N5TkpURld4NGNNNTBWdzZSNWZET2dpQzhic2ZmUzgKQkptb3VscnJaRE5OVmpHOG1XNmNMeHJZdlZRT3JSVmVjQ0ZJZ3NzQ2JBPT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo="]
452
-
453
- assert_equal expected_multi_cert, @settings.idp_cert_multi
454
- assert_equal "https://idp.examle.com/saml/metadata", @settings.idp_entity_id
455
- assert_equal "urn:oasis:names:tc:SAML:2.0:nameid-format:transient", @settings.name_identifier_format
456
- assert_equal "https://idp.examle.com/saml/sso", @settings.idp_sso_target_url
457
- assert_equal "https://idp.examle.com/saml/slo", @settings.idp_slo_target_url
458
- end
459
- end
460
-
461
- describe "parsing metadata with IDPSSODescriptor with same signature cert and encrypt cert" do
462
- before do
463
- @idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
464
- @idp_metadata = idp_metadata_same_sign_and_encrypt_cert
465
- @settings = @idp_metadata_parser.parse(@idp_metadata)
466
- end
467
-
468
- it "should return idp_cert and idp_cert_fingerprint and no idp_cert_multi" do
469
- assert_equal "MIIEHjCCAwagAwIBAgIBATANBgkqhkiG9w0BAQUFADBnMQswCQYDVQQGEwJVUzET
470
- MBEGA1UECAwKQ2FsaWZvcm5pYTEVMBMGA1UEBwwMU2FudGEgTW9uaWNhMREwDwYD
471
- VQQKDAhPbmVMb2d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qbC+fTGcV
487
- gG/4oKLJ5UwRFxInqpZPnOAudVNnd0PYOODn9FWs6u+OTIQIaIcPUv3MhB9lwHIJ
488
- sTk/bs9xcru5TPyLIxLLd6ib/pRceKH2mTkzUd0DYk9CQNXXeoGx/du5B9nh3ClP
489
- TbVakRzl3oswgI5MQIphYxkW70SopEh4kOFSRE1ND31NNIq1YrXlgtkguQBFsZWu
490
- QOPR6cEwFZzP0tHTYbI839WgxX6hfhIUTUz6mLqq4+3P4BG3+1OXeVDg63y8Uh78
491
- 1sE=", @settings.idp_cert
492
- assert_equal "2D:A9:40:88:28:EE:67:BB:4A:5B:E0:58:A7:CC:71:95:2D:1B:C9:D3", @settings.idp_cert_fingerprint
493
- assert_nil @settings.idp_cert_multi
494
- assert_equal "https://app.onelogin.com/saml/metadata/383123", @settings.idp_entity_id
495
- assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", @settings.name_identifier_format
496
- assert_equal "https://app.onelogin.com/trust/saml2/http-post/sso/383123", @settings.idp_sso_target_url
497
- assert_nil @settings.idp_slo_target_url
498
- end
499
- end
500
-
501
- describe "parsing metadata with IDPSSODescriptor with different signature cert and encrypt cert" do
502
- before do
503
- @idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
504
- @idp_metadata = idp_metadata_different_sign_and_encrypt_cert
505
- @settings = @idp_metadata_parser.parse(@idp_metadata)
506
- end
507
-
508
- it "should return a idp_cert_multi and no idp_cert and no idp_cert_fingerprint" do
509
- assert_nil @settings.idp_cert
510
- assert_nil @settings.idp_cert_fingerprint
511
-
512
- expected_multi_cert = {}
513
- expected_multi_cert[:signing] = ["MIIEHjCCAwagAwIBAgIBATANBgkqhkiG9w0BAQUFADBnMQswCQYDVQQGEwJVUzET
514
- MBEGA1UECAwKQ2FsaWZvcm5pYTEVMBMGA1UEBwwMU2FudGEgTW9uaWNhMREwDwYD
515
- VQQKDAhPbmVMb2dpbjEZMBcGA1UEAwwQYXBwLm9uZWxvZ2luLmNvbT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nd0PYOODn9FWs6u+OTIQIaIcPUv3MhB9lwHIJ
532
- sTk/bs9xcru5TPyLIxLLd6ib/pRceKH2mTkzUd0DYk9CQNXXeoGx/du5B9nh3ClP
533
- TbVakRzl3oswgI5MQIphYxkW70SopEh4kOFSRE1ND31NNIq1YrXlgtkguQBFsZWu
534
- QOPR6cEwFZzP0tHTYbI839WgxX6hfhIUTUz6mLqq4+3P4BG3+1OXeVDg63y8Uh78
535
- 1sE="]
536
- expected_multi_cert[:encryption] = ["MIIEZTCCA02gAwIBAgIUPyy/A3bZAZ4m28PzEUUoT7RJhxIwDQYJKoZIhvcNAQEF
537
- BQAwcjELMAkGA1UEBhMCVVMxKzApBgNVBAoMIk9uZUxvZ2luIFRlc3QgKHNnYXJj
538
- aWEtdXMtcHJlcHJvZCkxFTATBgNVBAsMDE9uZUxvZ2luIElkUDEfMB0GA1UEAwwW
539
- T25lTG9naW4gQWNjb3VudCA4OTE0NjAeFw0xNjA4MDQyMjI5MzdaFw0yMTA4MDUy
540
- MjI5MzdaMHIxCzAJBgNVBAYTAlVTMSswKQYDVQQKDCJPbmVMb2dpbiBUZXN0IChz
541
- Z2FyY2lhLXVzLXByZXByb2QpMRUwEwYDVQQLDAxPbmVMb2dpbiBJZFAxHzAdBgNV
542
- BAMMFk9uZUxvZ2luIEFjY291bnQgODkxNDYwggEiMA0GCSqGSIb3DQEBAQUAA4IB
543
- DwAwggEKAoIBAQDN6iqQGcLOCglNO42I2rkzE05UXSiMXT6c8ALThMMiaDw6qqzo
544
- 3sd/tKK+NcNKWLIIC8TozWVyh5ykUiVZps+08xil7VsTU7E+wKu3kvmOsvw2wlRw
545
- tnoKZJwYhnr+RkBa+h1r3ZYUgXm1ZPeHMKj1g18KaWz9+MxYL6BhKqrOzfW/P2xx
546
- VRcFH7/pq+ZsDdgNzD2GD+apzY4MZyZj/N6BpBWJ0GlFsmtBegpbX3LBitJuFkk5
547
- L4/U/jjF1AJa3boBdCUVfATqO5G03H4XS1GySjBIRQXmlUF52rLjg6xCgWJ30/+t
548
- 1X+IHLJeixiQ0vxyh6C4/usCEt94cgD1r8ADAgMBAAGjgfIwge8wDAYDVR0TAQH/
549
- BAIwADAdBgNVHQ4EFgQUPW0DcH0G3IwynWgi74co4wZ6n7gwga8GA1UdIwSBpzCB
550
- pIAUPW0DcH0G3IwynWgi74co4wZ6n7ihdqR0MHIxCzAJBgNVBAYTAlVTMSswKQYD
551
- VQQKDCJPbmVMb2dpbiBUZXN0IChzZ2FyY2lhLXVzLXByZXByb2QpMRUwEwYDVQQL
552
- DAxPbmVMb2dpbiBJZFAxHzAdBgNVBAMMFk9uZUxvZ2luIEFjY291bnQgODkxNDaC
553
- FD8svwN22QGeJtvD8xFFKE+0SYcSMA4GA1UdDwEB/wQEAwIHgDANBgkqhkiG9w0B
554
- AQUFAAOCAQEAQhB4q9jrycwbHrDSoYR1X4LFFzvJ9Us75wQquRHXpdyS9D6HUBXM
555
- GI6ahPicXCQrfLgN8vzMIiqZqfySXXv/8/dxe/X4UsWLYKYJHDJmxXD5EmWTa65c
556
- hjkeP1oJAc8f3CKCpcP2lOBTthbnk2fEVAeLHR4xNdQO0VvGXWO9BliYPpkYqUIB
557
- vlm+Fg9mF7AM/Uagq2503XXIE1Lq//HON68P10vNMwLSKOtYLsoTiCnuIKGJqG37
558
- MsZVjQ1ZPRcO+LSLkq0i91gFxrOrVCrgztX4JQi5XkvEsYZGIXXjwHqxTVyt3adZ
559
- WQO0LPxPqRiUqUzyhDhLo/xXNrHCu4VbMw=="]
560
-
561
- assert_equal expected_multi_cert, @settings.idp_cert_multi
562
- assert_equal "https://app.onelogin.com/saml/metadata/383123", @settings.idp_entity_id
563
- assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", @settings.name_identifier_format
564
- assert_equal "https://app.onelogin.com/trust/saml2/http-post/sso/383123", @settings.idp_sso_target_url
565
- assert_nil @settings.idp_slo_target_url
566
- end
567
- end
568
- end
data/test/logging_test.rb DELETED
@@ -1,62 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
2
-
3
- require 'onelogin/ruby-saml/logging'
4
-
5
- class LoggingTest < Minitest::Test
6
-
7
- describe "Logging" do
8
- before do
9
- OneLogin::RubySaml::Logging.logger = nil
10
- end
11
-
12
- after do
13
- OneLogin::RubySaml::Logging.logger = ::TEST_LOGGER
14
- end
15
-
16
- describe "given no specific logging setup" do
17
- it "prints to stdout" do
18
- OneLogin::RubySaml::Logging::DEFAULT_LOGGER.expects(:debug).with('hi mom')
19
- OneLogin::RubySaml::Logging.debug('hi mom')
20
- end
21
- end
22
-
23
- describe "given a Rails app" do
24
- let(:logger) { mock('Logger') }
25
-
26
- before do
27
- ::Rails = mock('Rails module')
28
- ::Rails.stubs(:logger).returns(logger)
29
- end
30
-
31
- after do
32
- Object.instance_eval { remove_const(:Rails) }
33
- end
34
-
35
- it "delegates to Rails" do
36
- logger.expects(:debug).with('hi mom')
37
- logger.expects(:info).with('sup?')
38
-
39
- OneLogin::RubySaml::Logging.debug('hi mom')
40
- OneLogin::RubySaml::Logging.info('sup?')
41
- end
42
- end
43
-
44
- describe "given a specific Logger" do
45
- let(:logger) { mock('Logger') }
46
-
47
- before { OneLogin::RubySaml::Logging.logger = logger }
48
-
49
- after do
50
- OneLogin::RubySaml::Logging.logger = ::TEST_LOGGER
51
- end
52
-
53
- it "delegates to the object" do
54
- logger.expects(:debug).with('hi mom')
55
- logger.expects(:info).with('sup?')
56
-
57
- OneLogin::RubySaml::Logging.debug('hi mom')
58
- OneLogin::RubySaml::Logging.info('sup?')
59
- end
60
- end
61
- end
62
- end
@@ -1,6 +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:Issuer xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'>https://app.onelogin.com/saml/metadata/SOMEACCOUNT</saml:Issuer>
4
- <saml:NameID xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'>someone@example.org</saml:NameID>
5
- <saml:NameID xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'>someone2@example.org</saml:NameID>
6
- </samlp:LogoutRequest>
@@ -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>