ruby-saml 0.8.13 → 0.8.14
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.
- data/lib/onelogin/ruby-saml/response.rb +46 -7
- data/lib/onelogin/ruby-saml/version.rb +1 -1
- data/lib/xml_security.rb +2 -0
- data/test/response_test.rb +174 -35
- data/test/xml_security_test.rb +47 -3
- metadata +24 -18
- checksums.yaml +0 -7
@@ -157,7 +157,7 @@ module OneLogin
|
|
157
157
|
validate_response_state(soft) &&
|
158
158
|
validate_conditions(soft) &&
|
159
159
|
validate_audience(soft) &&
|
160
|
-
|
160
|
+
validate_signature(soft) &&
|
161
161
|
success?
|
162
162
|
end
|
163
163
|
|
@@ -225,7 +225,6 @@ module OneLogin
|
|
225
225
|
|
226
226
|
if verified_seis.include?(sei)
|
227
227
|
return soft ? false : validation_error("Duplicated Reference URI. SAML Response rejected")
|
228
|
-
return append_error("Duplicated Reference URI. SAML Response rejected")
|
229
228
|
end
|
230
229
|
|
231
230
|
verified_seis.push(sei)
|
@@ -400,17 +399,57 @@ module OneLogin
|
|
400
399
|
true
|
401
400
|
end
|
402
401
|
|
402
|
+
def validate_signature(soft = true)
|
403
|
+
error_msg = "Invalid Signature on SAML Response"
|
404
|
+
|
405
|
+
sig_elements = REXML::XPath.match(
|
406
|
+
document,
|
407
|
+
"/p:Response[@ID=$id]/ds:Signature]",
|
408
|
+
{ "p" => PROTOCOL, "ds" => DSIG },
|
409
|
+
{ 'id' => document.signed_element_id }
|
410
|
+
)
|
411
|
+
|
412
|
+
# Check signature nodes
|
413
|
+
if sig_elements.nil? || sig_elements.size == 0
|
414
|
+
sig_elements = REXML::XPath.match(
|
415
|
+
document,
|
416
|
+
"/p:Response/a:Assertion[@ID=$id]/ds:Signature",
|
417
|
+
{"p" => PROTOCOL, "a" => ASSERTION, "ds"=>DSIG},
|
418
|
+
{ 'id' => document.signed_element_id }
|
419
|
+
)
|
420
|
+
end
|
421
|
+
|
422
|
+
if sig_elements.size != 1
|
423
|
+
if sig_elements.size == 0
|
424
|
+
error_msg += ". Signed element id ##{doc.signed_element_id} is not found"
|
425
|
+
else
|
426
|
+
error_msg += ". Signed element id ##{doc.signed_element_id} is found more than once"
|
427
|
+
end
|
428
|
+
return soft ? false : validation_error(error_msg)
|
429
|
+
end
|
430
|
+
|
431
|
+
opts = {}
|
432
|
+
opts[:fingerprint_alg] = OpenSSL::Digest::SHA1.new
|
433
|
+
opts[:cert] = settings.idp_cert
|
434
|
+
fingerprint = get_fingerprint
|
435
|
+
|
436
|
+
unless fingerprint
|
437
|
+
return soft ? false : validation_error("No fingerprint or certificate on settings")
|
438
|
+
end
|
439
|
+
|
440
|
+
unless document.validate_document(fingerprint, soft, opts)
|
441
|
+
return soft ? false : validation_error(error_msg)
|
442
|
+
end
|
443
|
+
|
444
|
+
true
|
445
|
+
end
|
446
|
+
|
403
447
|
def parse_time(node, attribute)
|
404
448
|
if node && node.attributes[attribute]
|
405
449
|
Time.parse(node.attributes[attribute])
|
406
450
|
end
|
407
451
|
end
|
408
452
|
|
409
|
-
# Validates the Audience, (If the Audience match the Service Provider EntityID)
|
410
|
-
# If fails, the error is added to the errors array
|
411
|
-
# @return [Boolean] True if there is an Audience Element that match the Service Provider EntityID, otherwise False if soft=True
|
412
|
-
# @raise [ValidationError] if soft == false and validation fails
|
413
|
-
#
|
414
453
|
def validate_audience(soft = true)
|
415
454
|
return true if audiences.empty? || settings.sp_entity_id.nil? || settings.sp_entity_id.empty?
|
416
455
|
|
data/lib/xml_security.rb
CHANGED
@@ -251,6 +251,8 @@ module XMLSecurity
|
|
251
251
|
if idp_cert.to_pem != cert.to_pem
|
252
252
|
return false
|
253
253
|
end
|
254
|
+
elsif not idp_cert
|
255
|
+
return soft ? false : (raise OneLogin::RubySaml::ValidationError.new("Certificate element missing in response (ds:X509Certificate) and not cert provided at settings"))
|
254
256
|
else
|
255
257
|
base64_cert = Base64.encode64(idp_cert.to_pem)
|
256
258
|
end
|
data/test/response_test.rb
CHANGED
@@ -4,7 +4,10 @@ class ResponseTest < Minitest::Test
|
|
4
4
|
|
5
5
|
describe "Response" do
|
6
6
|
it "raise an exception when response is initialized with nil" do
|
7
|
-
assert_raises(ArgumentError)
|
7
|
+
err = assert_raises(ArgumentError) do
|
8
|
+
OneLogin::RubySaml::Response.new(nil)
|
9
|
+
end
|
10
|
+
assert_equal "Response cannot be nil", err.message
|
8
11
|
end
|
9
12
|
|
10
13
|
it "be able to parse a document which contains ampersands" do
|
@@ -45,12 +48,71 @@ class ResponseTest < Minitest::Test
|
|
45
48
|
end
|
46
49
|
|
47
50
|
describe "#validate!" do
|
51
|
+
it "raise when settings not initialized" do
|
52
|
+
response = OneLogin::RubySaml::Response.new(response_document)
|
53
|
+
err = assert_raises(OneLogin::RubySaml::ValidationError) do
|
54
|
+
response.validate!
|
55
|
+
end
|
56
|
+
assert_equal "No settings on response", err.message
|
57
|
+
end
|
58
|
+
|
48
59
|
it "raise when encountering a condition that prevents the document from being valid" do
|
49
60
|
response = OneLogin::RubySaml::Response.new(response_document)
|
50
|
-
|
61
|
+
response.settings = settings
|
62
|
+
err = assert_raises(OneLogin::RubySaml::ValidationError) do
|
51
63
|
response.validate!
|
52
64
|
end
|
65
|
+
assert_equal "Current time is on or after NotOnOrAfter condition", err.message
|
53
66
|
end
|
67
|
+
|
68
|
+
it "raises an exception when no cert or fingerprint provided" do
|
69
|
+
response = OneLogin::RubySaml::Response.new(response_document_valid_signed)
|
70
|
+
response.stubs(:conditions).returns(nil)
|
71
|
+
settings = OneLogin::RubySaml::Settings.new
|
72
|
+
response.settings = settings
|
73
|
+
settings.idp_cert = nil
|
74
|
+
settings.idp_cert_fingerprint = nil
|
75
|
+
err = assert_raises(OneLogin::RubySaml::ValidationError) do
|
76
|
+
response.validate!
|
77
|
+
end
|
78
|
+
assert_equal "No fingerprint or certificate on settings", err.message
|
79
|
+
end
|
80
|
+
|
81
|
+
it "raise when no signature" do
|
82
|
+
response_no_signed_elements = OneLogin::RubySaml::Response.new(read_invalid_response("no_signature.xml.base64"))
|
83
|
+
settings.idp_cert_fingerprint = signature_fingerprint_1
|
84
|
+
response_no_signed_elements.settings = settings
|
85
|
+
err = assert_raises(OneLogin::RubySaml::ValidationError) do
|
86
|
+
response_no_signed_elements.validate!
|
87
|
+
end
|
88
|
+
assert_equal "Found an unexpected number of Signature Element. SAML Response rejected", err.message
|
89
|
+
end
|
90
|
+
|
91
|
+
it "raise when multiple signatures" do
|
92
|
+
response_multiple_signed = OneLogin::RubySaml::Response.new(read_invalid_response("multiple_signed.xml.base64"))
|
93
|
+
settings.idp_cert_fingerprint = signature_fingerprint_1
|
94
|
+
response_multiple_signed.settings = settings
|
95
|
+
response_multiple_signed.stubs(:validate_structure).returns(true)
|
96
|
+
err = assert_raises(OneLogin::RubySaml::ValidationError) do
|
97
|
+
response_multiple_signed.validate!
|
98
|
+
end
|
99
|
+
assert_equal "Duplicated ID. SAML Response rejected", err.message
|
100
|
+
end
|
101
|
+
|
102
|
+
it "raise when fingerprint missmatch" do
|
103
|
+
resp_xml = Base64.decode64(response_document_valid_signed)
|
104
|
+
response = OneLogin::RubySaml::Response.new(Base64.encode64(resp_xml))
|
105
|
+
response.stubs(:conditions).returns(nil)
|
106
|
+
settings = OneLogin::RubySaml::Settings.new
|
107
|
+
settings.idp_cert_fingerprint = signature_fingerprint_1
|
108
|
+
response.settings = settings
|
109
|
+
|
110
|
+
err = assert_raises(OneLogin::RubySaml::ValidationError) do
|
111
|
+
response.validate!
|
112
|
+
end
|
113
|
+
assert_equal 'Fingerprint mismatch', err.message
|
114
|
+
end
|
115
|
+
|
54
116
|
end
|
55
117
|
|
56
118
|
describe "#is_valid?" do
|
@@ -64,6 +126,16 @@ class ResponseTest < Minitest::Test
|
|
64
126
|
assert !response.is_valid?
|
65
127
|
end
|
66
128
|
|
129
|
+
it "return false when no cert or fingerprint provided" do
|
130
|
+
response = OneLogin::RubySaml::Response.new(response_document_valid_signed)
|
131
|
+
response.stubs(:conditions).returns(nil)
|
132
|
+
settings = OneLogin::RubySaml::Settings.new
|
133
|
+
response.settings = settings
|
134
|
+
settings.idp_cert = nil
|
135
|
+
settings.idp_cert_fingerprint = nil
|
136
|
+
assert !response.is_valid?
|
137
|
+
end
|
138
|
+
|
67
139
|
it "return true when the response is initialized with valid data" do
|
68
140
|
response = OneLogin::RubySaml::Response.new(response_document_valid_signed)
|
69
141
|
response.stubs(:conditions).returns(nil)
|
@@ -80,7 +152,7 @@ class ResponseTest < Minitest::Test
|
|
80
152
|
response = OneLogin::RubySaml::Response.new(response_document_valid_signed)
|
81
153
|
response.stubs(:conditions).returns(nil)
|
82
154
|
settings = OneLogin::RubySaml::Settings.new
|
83
|
-
response.settings = settings
|
155
|
+
response.settings = settings
|
84
156
|
assert !response.is_valid?
|
85
157
|
assert !response.is_valid?
|
86
158
|
end
|
@@ -95,7 +167,17 @@ class ResponseTest < Minitest::Test
|
|
95
167
|
assert response.is_valid?
|
96
168
|
end
|
97
169
|
|
98
|
-
it "return true when
|
170
|
+
it "return true when valid response and using fingerprint" do
|
171
|
+
response = OneLogin::RubySaml::Response.new(response_document_valid_signed)
|
172
|
+
response.stubs(:conditions).returns(nil)
|
173
|
+
settings = OneLogin::RubySaml::Settings.new
|
174
|
+
response.settings = settings
|
175
|
+
settings.idp_cert = nil
|
176
|
+
settings.idp_cert_fingerprint = "4B:68:C4:53:C7:D9:94:AA:D9:02:5C:99:D5:EF:CF:56:62:87:FE:8D"
|
177
|
+
assert response.is_valid?
|
178
|
+
end
|
179
|
+
|
180
|
+
it "return true when valid response using certificate" do
|
99
181
|
response = OneLogin::RubySaml::Response.new(response_document_valid_signed)
|
100
182
|
response.stubs(:conditions).returns(nil)
|
101
183
|
settings = OneLogin::RubySaml::Settings.new
|
@@ -126,26 +208,6 @@ class ResponseTest < Minitest::Test
|
|
126
208
|
assert_nil response_wrapped.name_id
|
127
209
|
end
|
128
210
|
|
129
|
-
it "raise when no signature" do
|
130
|
-
response_no_signed_elements = OneLogin::RubySaml::Response.new(read_invalid_response("no_signature.xml.base64"))
|
131
|
-
settings.idp_cert_fingerprint = signature_fingerprint_1
|
132
|
-
response_no_signed_elements.settings = settings
|
133
|
-
error_msg = "Found an unexpected number of Signature Element. SAML Response rejected"
|
134
|
-
assert_raises(OneLogin::RubySaml::ValidationError, error_msg) do
|
135
|
-
response_no_signed_elements.validate!
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
it "raise when multiple signatures" do
|
140
|
-
response_multiple_signed = OneLogin::RubySaml::Response.new(read_invalid_response("multiple_signed.xml.base64"))
|
141
|
-
settings.idp_cert_fingerprint = signature_fingerprint_1
|
142
|
-
response_multiple_signed.settings = settings
|
143
|
-
error_msg = "Duplicated ID. SAML Response rejected"
|
144
|
-
assert_raises(OneLogin::RubySaml::ValidationError, error_msg) do
|
145
|
-
response_multiple_signed.validate!
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
211
|
it "support dynamic namespace resolution on signature elements" do
|
150
212
|
response = OneLogin::RubySaml::Response.new(fixture("no_signature_ns.xml"))
|
151
213
|
response.stubs(:conditions).returns(nil)
|
@@ -156,6 +218,40 @@ class ResponseTest < Minitest::Test
|
|
156
218
|
assert response.validate!
|
157
219
|
end
|
158
220
|
|
221
|
+
it "support signature elements with no KeyInfo if cert provided" do
|
222
|
+
response = OneLogin::RubySaml::Response.new(response_document_valid_signed_without_x509certificate)
|
223
|
+
response.stubs(:conditions).returns(nil)
|
224
|
+
settings = OneLogin::RubySaml::Settings.new
|
225
|
+
response.settings = settings
|
226
|
+
settings.idp_cert = ruby_saml_cert
|
227
|
+
settings.idp_cert_fingerprint = nil
|
228
|
+
XMLSecurity::SignedDocument.any_instance.expects(:validate_signature).returns(true)
|
229
|
+
assert response.validate!
|
230
|
+
end
|
231
|
+
|
232
|
+
it "returns an error if the signature contains no KeyInfo, cert is not provided and soft" do
|
233
|
+
response = OneLogin::RubySaml::Response.new(response_document_valid_signed_without_x509certificate)
|
234
|
+
response.stubs(:conditions).returns(nil)
|
235
|
+
settings = OneLogin::RubySaml::Settings.new
|
236
|
+
response.settings = settings
|
237
|
+
settings.idp_cert = nil
|
238
|
+
settings.idp_cert_fingerprint = "28:74:9B:E8:1F:E8:10:9C:A8:7C:A9:C3:E3:C5:01:6C:92:1C:B4:BA"
|
239
|
+
assert !response.is_valid?
|
240
|
+
end
|
241
|
+
|
242
|
+
it "raises an exception if the signature contains no KeyInfo, cert is not provided and no soft" do
|
243
|
+
response = OneLogin::RubySaml::Response.new(response_document_valid_signed_without_x509certificate)
|
244
|
+
response.stubs(:conditions).returns(nil)
|
245
|
+
settings = OneLogin::RubySaml::Settings.new
|
246
|
+
response.settings = settings
|
247
|
+
settings.idp_cert = nil
|
248
|
+
settings.idp_cert_fingerprint = "28:74:9B:E8:1F:E8:10:9C:A8:7C:A9:C3:E3:C5:01:6C:92:1C:B4:BA"
|
249
|
+
err = assert_raises(OneLogin::RubySaml::ValidationError) do
|
250
|
+
response.validate!
|
251
|
+
end
|
252
|
+
assert_equal "Certificate element missing in response (ds:X509Certificate) and not cert provided at settings", err.message
|
253
|
+
end
|
254
|
+
|
159
255
|
it "validate ADFS assertions" do
|
160
256
|
response = OneLogin::RubySaml::Response.new(fixture(:adfs_response_sha256))
|
161
257
|
response.stubs(:conditions).returns(nil)
|
@@ -174,16 +270,6 @@ class ResponseTest < Minitest::Test
|
|
174
270
|
assert response.validate!
|
175
271
|
end
|
176
272
|
|
177
|
-
it "validate SAML 2.0 XML structure" do
|
178
|
-
resp_xml = Base64.decode64(response_document_valid_signed).gsub(/emailAddress/,'test')
|
179
|
-
response = OneLogin::RubySaml::Response.new(Base64.encode64(resp_xml))
|
180
|
-
response.stubs(:conditions).returns(nil)
|
181
|
-
settings = OneLogin::RubySaml::Settings.new
|
182
|
-
settings.idp_cert_fingerprint = signature_fingerprint_1
|
183
|
-
response.settings = settings
|
184
|
-
assert_raises(OneLogin::RubySaml::ValidationError, 'Digest mismatch'){ response.validate! }
|
185
|
-
end
|
186
|
-
|
187
273
|
it "Prevent node text with comment (VU#475445) attack" do
|
188
274
|
response_doc = File.read(File.join(File.dirname(__FILE__), "responses", 'response_node_text_attack.xml.base64'))
|
189
275
|
response = OneLogin::RubySaml::Response.new(response_doc)
|
@@ -272,6 +358,54 @@ class ResponseTest < Minitest::Test
|
|
272
358
|
end
|
273
359
|
end
|
274
360
|
|
361
|
+
describe "validate_signature" do
|
362
|
+
it "raises an exception when no cert or fingerprint provided" do
|
363
|
+
response = OneLogin::RubySaml::Response.new(response_document_valid_signed)
|
364
|
+
settings = OneLogin::RubySaml::Settings.new
|
365
|
+
response.settings = settings
|
366
|
+
settings.idp_cert = nil
|
367
|
+
settings.idp_cert_fingerprint = nil
|
368
|
+
err = assert_raises(OneLogin::RubySaml::ValidationError) do
|
369
|
+
response.send(:validate_signature, false)
|
370
|
+
end
|
371
|
+
assert_equal "No fingerprint or certificate on settings", err.message
|
372
|
+
end
|
373
|
+
|
374
|
+
it "raises an exception when wrong cert provided" do
|
375
|
+
response = OneLogin::RubySaml::Response.new(response_document_valid_signed)
|
376
|
+
settings = OneLogin::RubySaml::Settings.new
|
377
|
+
response.settings = settings
|
378
|
+
settings.idp_cert = ruby_saml_cert2
|
379
|
+
settings.idp_cert_fingerprint = nil
|
380
|
+
err = assert_raises(OneLogin::RubySaml::ValidationError) do
|
381
|
+
response.send(:validate_signature, false)
|
382
|
+
end
|
383
|
+
assert_equal "Fingerprint mismatch", err.message
|
384
|
+
end
|
385
|
+
|
386
|
+
it "raises an exception when wrong fingerprint provided" do
|
387
|
+
response = OneLogin::RubySaml::Response.new(response_document_valid_signed)
|
388
|
+
settings = OneLogin::RubySaml::Settings.new
|
389
|
+
response.settings = settings
|
390
|
+
settings.idp_cert = nil
|
391
|
+
settings.idp_cert_fingerprint = "28:74:9B:E8:1F:E8:10:9C:A8:7C:A9:C3:E3:C5:01:6C:92:1C:B4:BA"
|
392
|
+
err = assert_raises(OneLogin::RubySaml::ValidationError) do
|
393
|
+
response.send(:validate_signature, false)
|
394
|
+
end
|
395
|
+
assert_equal "Fingerprint mismatch", err.message
|
396
|
+
end
|
397
|
+
|
398
|
+
it "raises an exception when no signature" do
|
399
|
+
response_no_signed_elements = OneLogin::RubySaml::Response.new(read_invalid_response("no_signature.xml.base64"))
|
400
|
+
settings.idp_cert_fingerprint = signature_fingerprint_1
|
401
|
+
response_no_signed_elements.settings = settings
|
402
|
+
err = assert_raises(OneLogin::RubySaml::ValidationError) do
|
403
|
+
response_no_signed_elements.validate!
|
404
|
+
end
|
405
|
+
assert_equal "Found an unexpected number of Signature Element. SAML Response rejected", err.message
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
275
409
|
describe "#attributes" do
|
276
410
|
before do
|
277
411
|
@response = OneLogin::RubySaml::Response.new(response_document)
|
@@ -464,6 +598,10 @@ class ResponseTest < Minitest::Test
|
|
464
598
|
response_wrapped.stubs(:validate_subject_confirmation).returns(true)
|
465
599
|
settings.idp_cert_fingerprint = "385b1eec71143f00db6af936e2ea12a28771d72c"
|
466
600
|
assert !response_wrapped.is_valid?
|
601
|
+
err = assert_raises(OneLogin::RubySaml::ValidationError) do
|
602
|
+
response_wrapped.validate!
|
603
|
+
end
|
604
|
+
assert_equal "Found an invalid Signed Element. SAML Response rejected", err.message
|
467
605
|
end
|
468
606
|
end
|
469
607
|
|
@@ -475,8 +613,9 @@ class ResponseTest < Minitest::Test
|
|
475
613
|
settings.idp_cert_fingerprint = '4b68c453c7d994aad9025c99d5efcf566287fe8d'
|
476
614
|
response_wrapped.stubs(:conditions).returns(nil)
|
477
615
|
response_wrapped.stubs(:validate_subject_confirmation).returns(true)
|
616
|
+
response_wrapped.stubs(:validate_structure).returns(true)
|
478
617
|
assert !response_wrapped.is_valid?
|
479
|
-
|
618
|
+
assert !response_wrapped.validate!
|
480
619
|
end
|
481
620
|
end
|
482
621
|
|
data/test/xml_security_test.rb
CHANGED
@@ -295,7 +295,7 @@ class XmlSecurityTest < Minitest::Test
|
|
295
295
|
end
|
296
296
|
|
297
297
|
describe "StarfieldTMS" do
|
298
|
-
before do
|
298
|
+
before do
|
299
299
|
@response = OneLogin::RubySaml::Response.new(fixture(:starfield_response))
|
300
300
|
@response.settings = OneLogin::RubySaml::Settings.new( :idp_cert_fingerprint => "8D:BA:53:8E:A3:B6:F9:F1:69:6C:BB:D9:D8:BD:41:B3:AC:4F:9D:4D")
|
301
301
|
end
|
@@ -373,6 +373,35 @@ class XmlSecurityTest < Minitest::Test
|
|
373
373
|
assert document.name_id.nil?, 'Document should expose only signed, valid details'
|
374
374
|
end
|
375
375
|
end
|
376
|
+
|
377
|
+
describe 'when response has no cert and you provide cert' do
|
378
|
+
let(:document) { OneLogin::RubySaml::Response.new(response_document_valid_signed_without_x509certificate).document }
|
379
|
+
let(:idp_cert) { OpenSSL::X509::Certificate.new(ruby_saml_cert_text) }
|
380
|
+
let(:options) { {} }
|
381
|
+
|
382
|
+
it 'is valid' do
|
383
|
+
options[:cert] = idp_cert
|
384
|
+
assert document.document.validate_document(idp_cert, true, options), 'Document should be valid'
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
describe 'when response has no cert and you dont provide cert' do
|
389
|
+
let(:document) { OneLogin::RubySaml::Response.new(response_document_valid_signed_without_x509certificate).document }
|
390
|
+
let(:options) { {} }
|
391
|
+
let(:idp_cert) { nil }
|
392
|
+
|
393
|
+
it 'is invalid' do
|
394
|
+
options[:cert] = idp_cert
|
395
|
+
assert !document.document.validate_document(idp_cert, true, options), 'Document should not be valid'
|
396
|
+
end
|
397
|
+
|
398
|
+
it 'is invalid and error raised' do
|
399
|
+
options[:cert] = idp_cert
|
400
|
+
assert_raises(OneLogin::RubySaml::ValidationError) do
|
401
|
+
document.document.validate_document(idp_cert, false, options)
|
402
|
+
end
|
403
|
+
end
|
404
|
+
end
|
376
405
|
end
|
377
406
|
|
378
407
|
describe '#validate_document_with_cert' do
|
@@ -387,8 +416,8 @@ class XmlSecurityTest < Minitest::Test
|
|
387
416
|
assert document.validate_document_with_cert(idp_cert), 'Document should be valid'
|
388
417
|
end
|
389
418
|
end
|
390
|
-
|
391
|
-
describe 'when response has no cert
|
419
|
+
|
420
|
+
describe 'when response has no cert and you provide cert' do
|
392
421
|
let(:document) { OneLogin::RubySaml::Response.new(response_document_valid_signed_without_x509certificate).document }
|
393
422
|
let(:idp_cert) { OpenSSL::X509::Certificate.new(ruby_saml_cert_text) }
|
394
423
|
|
@@ -396,6 +425,21 @@ class XmlSecurityTest < Minitest::Test
|
|
396
425
|
assert document.validate_document_with_cert(idp_cert), 'Document should be valid'
|
397
426
|
end
|
398
427
|
end
|
428
|
+
|
429
|
+
describe 'when response has no cert and you dont provide cert' do
|
430
|
+
let(:document) { OneLogin::RubySaml::Response.new(response_document_valid_signed_without_x509certificate).document }
|
431
|
+
let(:idp_cert) { nil }
|
432
|
+
|
433
|
+
it 'is invalid' do
|
434
|
+
assert !document.validate_document_with_cert(idp_cert), 'Document should not be valid'
|
435
|
+
end
|
436
|
+
|
437
|
+
it 'is invalid and error raised' do
|
438
|
+
assert_raises(OneLogin::RubySaml::ValidationError) do
|
439
|
+
document.validate_document_with_cert(idp_cert, false)
|
440
|
+
end
|
441
|
+
end
|
442
|
+
end
|
399
443
|
end
|
400
444
|
end
|
401
445
|
end
|
metadata
CHANGED
@@ -1,41 +1,46 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-saml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.14
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- OneLogin LLC
|
8
|
-
autorequire:
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2020-
|
12
|
+
date: 2020-10-19 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: uuid
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- -
|
19
|
+
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '2.3'
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '2.3'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: nokogiri
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- -
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: 1.5.0
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- -
|
43
|
+
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: 1.5.0
|
41
46
|
description: SAML toolkit for Ruby on Rails
|
@@ -46,9 +51,9 @@ extra_rdoc_files:
|
|
46
51
|
- LICENSE
|
47
52
|
- README.md
|
48
53
|
files:
|
49
|
-
-
|
50
|
-
-
|
51
|
-
-
|
54
|
+
- .document
|
55
|
+
- .gitignore
|
56
|
+
- .travis.yml
|
52
57
|
- Gemfile
|
53
58
|
- LICENSE
|
54
59
|
- README.md
|
@@ -127,27 +132,28 @@ files:
|
|
127
132
|
- test/xml_security_test.rb
|
128
133
|
homepage: http://github.com/onelogin/ruby-saml
|
129
134
|
licenses: []
|
130
|
-
|
131
|
-
post_install_message:
|
135
|
+
post_install_message:
|
132
136
|
rdoc_options:
|
133
|
-
-
|
137
|
+
- --charset=UTF-8
|
134
138
|
require_paths:
|
135
139
|
- lib
|
136
140
|
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
none: false
|
137
142
|
requirements:
|
138
|
-
- -
|
143
|
+
- - ! '>='
|
139
144
|
- !ruby/object:Gem::Version
|
140
145
|
version: '0'
|
141
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
142
148
|
requirements:
|
143
|
-
- -
|
149
|
+
- - ! '>='
|
144
150
|
- !ruby/object:Gem::Version
|
145
151
|
version: '0'
|
146
152
|
requirements: []
|
147
153
|
rubyforge_project: http://www.rubygems.org/gems/ruby-saml
|
148
|
-
rubygems_version:
|
149
|
-
signing_key:
|
150
|
-
specification_version:
|
154
|
+
rubygems_version: 1.8.23.2
|
155
|
+
signing_key:
|
156
|
+
specification_version: 3
|
151
157
|
summary: SAML Ruby Tookit
|
152
158
|
test_files:
|
153
159
|
- test/certificates/certificate1
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: c3f3a436bf74c3342e13ed40b9d6d7c71e8b25f1
|
4
|
-
data.tar.gz: c39cb2b2fa7844d97cd83e2d6a34f7a5ab68151e
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 38e6e375700d52f5bd4300dc5a1e7b9b20e5283b00371418730b1857ffc9b98857e72066a9ea67b504953eddaefc8683a0d40a29156f614dc18f9aaea7e7e0e5
|
7
|
-
data.tar.gz: a93d2f2c35bed0a8c44db64e3672aa8e811883d37b0386618dd51d0d7a9f19ddd37c59381dfa2c94cc04a361f3ecce8cd9677dc9ab6f44dee4eb653fefedba91
|