ruby-saml 0.5.3 → 0.6.0
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/.gitignore +5 -0
- data/.travis.yml +5 -0
- data/Gemfile +10 -6
- data/{README.rdoc → README.md} +31 -26
- data/lib/onelogin/ruby-saml/authrequest.rb +23 -18
- data/lib/onelogin/ruby-saml/logging.rb +4 -0
- data/lib/onelogin/ruby-saml/logoutrequest.rb +80 -0
- data/lib/onelogin/ruby-saml/response.rb +38 -4
- data/lib/onelogin/ruby-saml/settings.rb +10 -1
- data/lib/onelogin/ruby-saml/version.rb +1 -1
- data/lib/ruby-saml.rb +1 -0
- data/lib/schemas/saml20assertion_schema.xsd +283 -0
- data/lib/schemas/saml20protocol_schema.xsd +302 -0
- data/lib/schemas/xenc_schema.xsd +146 -0
- data/lib/schemas/xmldsig_schema.xsd +318 -0
- data/lib/xml_security.rb +52 -36
- data/ruby-saml.gemspec +4 -26
- data/test/logoutrequest_test.rb +98 -0
- data/test/response_test.rb +40 -2
- data/test/responses/adfs_response_sha1.xml +46 -0
- data/test/responses/{adfs_response.xml → adfs_response_sha256.xml} +0 -0
- data/test/responses/adfs_response_sha384.xml +46 -0
- data/test/responses/adfs_response_sha512.xml +46 -0
- data/test/responses/no_signature_ns.xml +48 -0
- data/test/settings_test.rb +22 -2
- data/test/test_helper.rb +2 -0
- data/test/xml_security_test.rb +103 -4
- metadata +79 -105
- data/Gemfile.lock +0 -38
@@ -0,0 +1,46 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="_0263a07b-205f-479c-90fc-7495715ecbbf" Version="2.0" IssueInstant="2011-06-22T12:49:30.348Z" Destination="https://someone.example.com/endpoint" Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" InResponseTo="_fc4a34b0-7efb-012e-caae-782bcb13bb38">
|
3
|
+
<Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">http://login.example.com/issuer</Issuer>
|
4
|
+
<samlp:Status>
|
5
|
+
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
|
6
|
+
</samlp:Status>
|
7
|
+
<Assertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion" ID="_721b4a5a-d7e1-4861-9754-a9b197b6f9ab" IssueInstant="2011-06-22T12:49:30.348Z" Version="2.0">
|
8
|
+
<Issuer>http://login.example.com/issuer</Issuer>
|
9
|
+
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
|
10
|
+
<ds:SignedInfo>
|
11
|
+
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
|
12
|
+
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha512"/>
|
13
|
+
<ds:Reference URI="#_721b4a5a-d7e1-4861-9754-a9b197b6f9ab">
|
14
|
+
<ds:Transforms>
|
15
|
+
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
|
16
|
+
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
|
17
|
+
</ds:Transforms>
|
18
|
+
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha512"/>
|
19
|
+
<ds:DigestValue>ZiOdC+GEvslNaP+yncB5droDFBwPeK9EjIpQ2LEI+y/3KPtIjGlp+eEQTVROxq3pqxJiNmSHJvtHzxytxzZsew==</ds:DigestValue>
|
20
|
+
</ds:Reference>
|
21
|
+
</ds:SignedInfo>
|
22
|
+
<ds:SignatureValue>JyaWS+PkmpsYZOcjb1Hws3RL1hlyfBY9VeUb7R/5UbeaESpS5Pe2dpfbYWZiOmY/3aYmkv9AEgveVwjddwp+wTQ4jZ91LG8L+ObX1Coq/j0Yj8aXeOBMxdueYmvJQGjHSEn2z0oKypGnbzM5gP/V8Aixa+e1/Kv+A/GcOX1K4SA=</ds:SignatureValue>
|
23
|
+
<KeyInf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3WURWUjBQQkFRRApBZ1VnTUIwR0ExVWREZ1FXQkJTUk9OOEdKOG8rOGpnRnRqa3R3WmRxeDZCUnlUQVRCZ05WSFNVRUREQUtCZ2dyCkJnRUZCUWNEQVRBZEJnbGdoa2dCaHZoQ0FRMEVFQllPVkdWemRDQllOVEE1SUdObGNuUXdnYk1HQTFVZEl3U0IKcXpDQnFJQVVrVGpmQmlmS1B2STRCYlk1TGNHWGFzZWdVY21oZ1l5a2dZa3dnWVl4Q3pBSkJnTlZCQVlUQWtGVgpNUXd3Q2dZRFZRUUlFd05PVTFjeER6QU5CZ05WQkFjVEJsTjVaRzVsZVRFTU1Bb0dBMVVFQ2d3RFVFbFVNUWt3CkJ3WURWUVFMREFBeEdEQVdCZ05WQkFNTUQyeGhkM0psYm1ObGNHbDBMbU52YlRFbE1DTUdDU3FHU0liM0RRRUoKQVF3V2JHRjNjbVZ1WTJVdWNHbDBRR2R0WVdsc0xtTnZiWUlCQVRBTkJna3Foa2lHOXcwQkFRc0ZBQU9CZ1FDRQpUQWVKVERTQVc2ejFVRlRWN1FyZWg0VUxGT1JhajkrZUN1RjNLV0RIYyswSVFDajlyZG5ERzRRL3dmNy9yYVEwCkpuUFFDU0NkclBMSmV5b1BIN1FhVHdvYUY3ZHpWdzRMQ3N5TkpURld4NGNNNTBWdzZSNWZET2dpQzhic2ZmUzgKQkptb3VscnJaRE5OVmpHOG1XNmNMeHJZdlZRT3JSVmVjQ0ZJZ3NzQ2JBPT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=</ds:X509Certificate>
|
26
|
+
</ds:X509Data>
|
27
|
+
</KeyInfo>
|
28
|
+
</ds:Signature>
|
29
|
+
<Subject>
|
30
|
+
<NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">hello@example.com</NameID>
|
31
|
+
<SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
|
32
|
+
<SubjectConfirmationData InResponseTo="_fc4a34b0-7efb-012e-caae-782bcb13bb38" NotOnOrAfter="2011-06-22T12:54:30.348Z" Recipient="https://someone.example.com/endpoint"/>
|
33
|
+
</SubjectConfirmation>
|
34
|
+
</Subject>
|
35
|
+
<Conditions NotBefore="2011-06-22T12:49:30.332Z" NotOnOrAfter="2011-06-22T13:49:30.332Z">
|
36
|
+
<AudienceRestriction>
|
37
|
+
<Audience>example.com</Audience>
|
38
|
+
</AudienceRestriction>
|
39
|
+
</Conditions>
|
40
|
+
<AuthnStatement AuthnInstant="2011-06-22T12:49:30.112Z" SessionIndex="_721b4a5a-d7e1-4861-9754-a9b197b6f9ab">
|
41
|
+
<AuthnContext>
|
42
|
+
<AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</AuthnContextClassRef>
|
43
|
+
</AuthnContext>
|
44
|
+
</AuthnStatement>
|
45
|
+
</Assertion>
|
46
|
+
</samlp:Response>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="_6b02a2b5-496b-4acc-a3c5-c86d0e9a3825" Version="2.0" IssueInstant="2012-04-04T07:33:10.921Z" Destination="https://example.com/endpoint">
|
3
|
+
<saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">idp.example.com</saml:Issuer>
|
4
|
+
<samlp:Status>
|
5
|
+
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
|
6
|
+
</samlp:Status>
|
7
|
+
<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" Version="2.0" ID="_cc084213-c9df-45ef-87a0-263f4da4f79b" IssueInstant="2012-04-04T07:33:10.923Z">
|
8
|
+
<saml:Issuer>idp.myexample.org</saml:Issuer>
|
9
|
+
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
|
10
|
+
<SignedInfo>
|
11
|
+
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
|
12
|
+
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
|
13
|
+
<Reference URI="#_cc084213-c9df-45ef-87a0-263f4da4f79b">
|
14
|
+
<Transforms>
|
15
|
+
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
|
16
|
+
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
|
17
|
+
<InclusiveNamespaces xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="#default saml ds xs xsi"/>
|
18
|
+
</Transform>
|
19
|
+
</Transforms>
|
20
|
+
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
|
21
|
+
<DigestValue>WFNjs7vC+IquRrJ7v7Q2YGGa7R0=</DigestValue>
|
22
|
+
</Reference>
|
23
|
+
</SignedInfo>
|
24
|
+
<SignatureValue>MmuXQdjutiuP7soIaB7nk9wSR8OGkmyH5n9aelMTOrV7gTVNDazgQ/GXMmYXTTrhdvGN65duLO0oYdsYGxwNIjlA1lYhoGeBgYuIB/4iKZ6oLSDgjMcQxHkSW1OJ8pIEuUa/3MPUUjaSlTg0me4WRxVdXp34A9Mtlj0DgrK9m0A=</SignatureValue>
|
25
|
+
<KeyInfo>
|
26
|
+
<X509Data>
|
27
|
+
<X509Certificate>LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUQwRENDQXptZ0F3SUJBZ0lCQVRBTkJna3Foa2lHOXcwQkFRVUZBRENCaGpFTE1Ba0dBMVVFQmhNQ1FWVXgKRERBS0JnTlZCQWdUQTA1VFZ6RVBNQTBHQTFVRUJ4TUdVM2xrYm1WNU1Rd3dDZ1lEVlFRS0RBTlFTVlF4Q1RBSApCZ05WQkFzTUFERVlNQllHQTFVRUF3d1BiR0YzY21WdVkyVndhWFF1WTI5dE1TVXdJd1lKS29aSWh2Y05BUWtCCkRCWnNZWGR5Wlc1alpTNXdhWFJBWjIxaGFXd3VZ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JBb01BMUJKVkRFSk1BY0dBMVVFQ3d3QU1SZ3cKRmdZRFZRUUREQTlzWVhkeVpXNWpaWEJwZEM1amIyMHhKVEFqQmdrcWhraUc5dzBCQ1FFTUZteGhkM0psYm1ObApMbkJwZEVCbmJXRnBiQzVqYjIyQ0FRRXdEUVlKS29aSWh2Y05BUUVGQlFBRGdZRUFOM2VRMUM5T0JJbVgvdWZGClNIUC9FeUxPQjJPQ1dqdlNpSytNbndQRWsralRRdDZZYXIxMkRacWVnRGhrWC92OGplTWh4VnpwaStBcHA4M0YKYWFmUE54UFJYc01FTFRCblhDQUJ1YzZEakxBaFlvNGQ4TDhCWUovVjlxLzZRMzdNYVZmc0ZKWVVKNmFBQUppWQpwd1RMUWJidFpqaytZc0s5TzZFR1U4ZjE5djg9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K</X509Certificate>
|
28
|
+
</X509Data>
|
29
|
+
</KeyInfo>
|
30
|
+
</Signature>
|
31
|
+
<saml:Subject>
|
32
|
+
<saml:NameID NameQualifier="idp.example.com" Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">someone@example.org</saml:NameID>
|
33
|
+
<saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
|
34
|
+
<saml:SubjectConfirmationData Recipient="https://example.com/endpoint" InResponseTo="_f7201940-6055-012f-3bc1-782bcb13c426"/>
|
35
|
+
</saml:SubjectConfirmation>
|
36
|
+
</saml:Subject>
|
37
|
+
<saml:Conditions NotBefore="2012-04-04T07:28:11.442Z" NotOnOrAfter="2012-04-04T07:38:11.442Z">
|
38
|
+
<saml:AudienceRestriction>
|
39
|
+
<saml:Audience>example.com</saml:Audience>
|
40
|
+
</saml:AudienceRestriction>
|
41
|
+
</saml:Conditions>
|
42
|
+
<saml:AuthnStatement AuthnInstant="2012-04-04T07:33:11.442Z">
|
43
|
+
<saml:AuthnContext>
|
44
|
+
<saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef>
|
45
|
+
</saml:AuthnContext>
|
46
|
+
</saml:AuthnStatement>
|
47
|
+
</saml:Assertion>
|
48
|
+
</samlp:Response>
|
data/test/settings_test.rb
CHANGED
@@ -8,8 +8,9 @@ class SettingsTest < Test::Unit::TestCase
|
|
8
8
|
end
|
9
9
|
should "should provide getters and settings" do
|
10
10
|
accessors = [
|
11
|
-
:assertion_consumer_service_url, :issuer, :sp_name_qualifier,
|
12
|
-
:idp_sso_target_url, :idp_cert_fingerprint, :name_identifier_format
|
11
|
+
:assertion_consumer_service_url, :issuer, :sp_name_qualifier,
|
12
|
+
:idp_sso_target_url, :idp_cert_fingerprint, :name_identifier_format,
|
13
|
+
:idp_slo_target_url, :name_identifier_value, :sessionindex
|
13
14
|
]
|
14
15
|
|
15
16
|
accessors.each do |accessor|
|
@@ -18,6 +19,25 @@ class SettingsTest < Test::Unit::TestCase
|
|
18
19
|
assert_equal value, @settings.send(accessor)
|
19
20
|
end
|
20
21
|
end
|
22
|
+
|
23
|
+
should "create settings from hash" do
|
24
|
+
|
25
|
+
config = {
|
26
|
+
:assertion_consumer_service_url => "http://app.muda.no/sso",
|
27
|
+
:issuer => "http://muda.no",
|
28
|
+
:sp_name_qualifier => "http://sso.muda.no",
|
29
|
+
:idp_sso_target_url => "http://sso.muda.no/sso",
|
30
|
+
:idp_slo_target_url => "http://sso.muda.no/slo",
|
31
|
+
:idp_cert_fingerprint => "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
|
32
|
+
:name_identifier_format => "urn:oasis:names:tc:SAML:2.0:nameid-format:transient",
|
33
|
+
}
|
34
|
+
@settings = Onelogin::Saml::Settings.new(config)
|
35
|
+
|
36
|
+
config.each do |k,v|
|
37
|
+
assert_equal v, @settings.send(k)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
21
41
|
end
|
22
42
|
|
23
43
|
end
|
data/test/test_helper.rb
CHANGED
@@ -8,6 +8,8 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
8
8
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
9
9
|
require 'ruby-saml'
|
10
10
|
|
11
|
+
ENV["ruby-saml/testing"] = "1"
|
12
|
+
|
11
13
|
class Test::Unit::TestCase
|
12
14
|
def fixture(document, base64 = true)
|
13
15
|
response = Dir.glob(File.join(File.dirname(__FILE__), "responses", "#{document}*")).first
|
data/test/xml_security_test.rb
CHANGED
@@ -3,22 +3,121 @@ require 'xml_security'
|
|
3
3
|
|
4
4
|
class XmlSecurityTest < Test::Unit::TestCase
|
5
5
|
include XMLSecurity
|
6
|
+
|
6
7
|
context "XmlSecurity" do
|
7
8
|
setup do
|
8
9
|
@document = XMLSecurity::SignedDocument.new(Base64.decode64(response_document))
|
10
|
+
@base64cert = @document.elements["//ds:X509Certificate"].text
|
9
11
|
end
|
10
12
|
|
11
13
|
should "should run validate without throwing NS related exceptions" do
|
12
|
-
|
13
|
-
|
14
|
+
assert !@document.validate_doc(@base64cert, true)
|
15
|
+
end
|
16
|
+
|
17
|
+
should "should run validate with throwing NS related exceptions" do
|
18
|
+
assert_raise(Onelogin::Saml::ValidationError) do
|
19
|
+
@document.validate_doc(@base64cert, false)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
should "not raise an error when softly validating the document multiple times" do
|
24
|
+
assert_nothing_raised do
|
25
|
+
2.times { @document.validate_doc(@base64cert, true) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
should "should raise Fingerprint mismatch" do
|
30
|
+
exception = assert_raise(Onelogin::Saml::ValidationError) do
|
31
|
+
@document.validate("no:fi:ng:er:pr:in:t", false)
|
32
|
+
end
|
33
|
+
assert_equal("Fingerprint mismatch", exception.message)
|
34
|
+
end
|
35
|
+
|
36
|
+
should "should raise Digest mismatch" do
|
37
|
+
exception = assert_raise(Onelogin::Saml::ValidationError) do
|
38
|
+
@document.validate_doc(@base64cert, false)
|
39
|
+
end
|
40
|
+
assert_equal("Digest mismatch", exception.message)
|
41
|
+
end
|
42
|
+
|
43
|
+
should "should raise Key validation error" do
|
44
|
+
response = Base64.decode64(response_document)
|
45
|
+
response.sub!("<ds:DigestValue>pJQ7MS/ek4KRRWGmv/H43ReHYMs=</ds:DigestValue>",
|
46
|
+
"<ds:DigestValue>b9xsAXLsynugg3Wc1CI3kpWku+0=</ds:DigestValue>")
|
47
|
+
document = XMLSecurity::SignedDocument.new(response)
|
48
|
+
base64cert = document.elements["//ds:X509Certificate"].text
|
49
|
+
exception = assert_raise(Onelogin::Saml::ValidationError) do
|
50
|
+
document.validate_doc(base64cert, false)
|
51
|
+
end
|
52
|
+
assert_equal("Key validation error", exception.message)
|
14
53
|
end
|
15
54
|
end
|
16
55
|
|
17
|
-
context "
|
56
|
+
context "Algorithms" do
|
57
|
+
should "validate using SHA1" do
|
58
|
+
@document = XMLSecurity::SignedDocument.new(fixture(:adfs_response_sha1, false))
|
59
|
+
assert @document.validate("F1:3C:6B:80:90:5A:03:0E:6C:91:3E:5D:15:FA:DD:B0:16:45:48:72")
|
60
|
+
end
|
61
|
+
|
18
62
|
should "validate using SHA256" do
|
19
|
-
@document = XMLSecurity::SignedDocument.new(fixture(:
|
63
|
+
@document = XMLSecurity::SignedDocument.new(fixture(:adfs_response_sha256, false))
|
20
64
|
assert @document.validate("28:74:9B:E8:1F:E8:10:9C:A8:7C:A9:C3:E3:C5:01:6C:92:1C:B4:BA")
|
21
65
|
end
|
66
|
+
|
67
|
+
should "validate using SHA384" do
|
68
|
+
@document = XMLSecurity::SignedDocument.new(fixture(:adfs_response_sha384, false))
|
69
|
+
assert @document.validate("F1:3C:6B:80:90:5A:03:0E:6C:91:3E:5D:15:FA:DD:B0:16:45:48:72")
|
70
|
+
end
|
71
|
+
|
72
|
+
should "validate using SHA512" do
|
73
|
+
@document = XMLSecurity::SignedDocument.new(fixture(:adfs_response_sha512, false))
|
74
|
+
assert @document.validate("F1:3C:6B:80:90:5A:03:0E:6C:91:3E:5D:15:FA:DD:B0:16:45:48:72")
|
75
|
+
end
|
22
76
|
end
|
77
|
+
|
78
|
+
context "XmlSecurity::SignedDocument" do
|
79
|
+
|
80
|
+
context "#extract_inclusive_namespaces" do
|
81
|
+
should "support explicit namespace resolution for exclusive canonicalization" do
|
82
|
+
response = fixture(:open_saml_response, false)
|
83
|
+
document = XMLSecurity::SignedDocument.new(response)
|
84
|
+
inclusive_namespaces = document.send(:extract_inclusive_namespaces)
|
85
|
+
|
86
|
+
assert_equal %w[ xs ], inclusive_namespaces
|
87
|
+
end
|
88
|
+
|
89
|
+
should "support implicit namespace resolution for exclusive canonicalization" do
|
90
|
+
response = fixture(:no_signature_ns, false)
|
91
|
+
document = XMLSecurity::SignedDocument.new(response)
|
92
|
+
inclusive_namespaces = document.send(:extract_inclusive_namespaces)
|
93
|
+
|
94
|
+
assert_equal %w[ #default saml ds xs xsi ], inclusive_namespaces
|
95
|
+
end
|
96
|
+
|
97
|
+
should_eventually 'support inclusive canonicalization' do
|
98
|
+
|
99
|
+
response = Onelogin::Saml::Response.new(fixture("tdnf_response.xml"))
|
100
|
+
response.stubs(:conditions).returns(nil)
|
101
|
+
assert !response.is_valid?
|
102
|
+
settings = Onelogin::Saml::Settings.new
|
103
|
+
assert !response.is_valid?
|
104
|
+
response.settings = settings
|
105
|
+
assert !response.is_valid?
|
106
|
+
settings.idp_cert_fingerprint = "e6 38 9a 20 b7 4f 13 db 6a bc b1 42 6a e7 52 1d d6 56 d4 1b".upcase.gsub(" ", ":")
|
107
|
+
assert response.validate!
|
108
|
+
end
|
23
109
|
|
110
|
+
should "return an empty list when inclusive namespace element is missing" do
|
111
|
+
response = fixture(:no_signature_ns, false)
|
112
|
+
response.slice! %r{<InclusiveNamespaces xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="#default saml ds xs xsi"/>}
|
113
|
+
|
114
|
+
document = XMLSecurity::SignedDocument.new(response)
|
115
|
+
inclusive_namespaces = document.send(:extract_inclusive_namespaces)
|
116
|
+
|
117
|
+
assert inclusive_namespaces.empty?
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
24
123
|
end
|
metadata
CHANGED
@@ -1,126 +1,103 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-saml
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 5
|
9
|
-
- 3
|
10
|
-
version: 0.5.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- OneLogin LLC
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-11-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: canonix
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 1
|
33
|
-
version: "0.1"
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.1.1
|
34
22
|
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: uuid
|
38
23
|
prerelease: false
|
39
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.1.1
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: uuid
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
40
33
|
none: false
|
41
|
-
requirements:
|
34
|
+
requirements:
|
42
35
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
segments:
|
46
|
-
- 2
|
47
|
-
- 3
|
48
|
-
version: "2.3"
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '2.3'
|
49
38
|
type: :runtime
|
50
|
-
version_requirements: *id002
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
|
-
name: shoulda
|
53
39
|
prerelease: false
|
54
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
55
41
|
none: false
|
56
|
-
requirements:
|
57
|
-
- -
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
type: :development
|
64
|
-
version_requirements: *id003
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name: ruby-debug
|
67
|
-
prerelease: false
|
68
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.3'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: nokogiri
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
69
49
|
none: false
|
70
|
-
requirements:
|
71
|
-
- -
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
|
74
|
-
|
75
|
-
- 0
|
76
|
-
version: "0"
|
77
|
-
type: :development
|
78
|
-
version_requirements: *id004
|
79
|
-
- !ruby/object:Gem::Dependency
|
80
|
-
name: mocha
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
81
55
|
prerelease: false
|
82
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
57
|
none: false
|
84
|
-
requirements:
|
85
|
-
- -
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
|
88
|
-
segments:
|
89
|
-
- 0
|
90
|
-
version: "0"
|
91
|
-
type: :development
|
92
|
-
version_requirements: *id005
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
93
62
|
description: SAML toolkit for Ruby on Rails
|
94
63
|
email: support@onelogin.com
|
95
64
|
executables: []
|
96
|
-
|
97
65
|
extensions: []
|
98
|
-
|
99
|
-
extra_rdoc_files:
|
66
|
+
extra_rdoc_files:
|
100
67
|
- LICENSE
|
101
|
-
- README.
|
102
|
-
files:
|
68
|
+
- README.md
|
69
|
+
files:
|
103
70
|
- .document
|
104
71
|
- .gitignore
|
72
|
+
- .travis.yml
|
105
73
|
- Gemfile
|
106
|
-
- Gemfile.lock
|
107
74
|
- LICENSE
|
108
|
-
- README.
|
75
|
+
- README.md
|
109
76
|
- Rakefile
|
110
77
|
- lib/onelogin/ruby-saml/authrequest.rb
|
111
78
|
- lib/onelogin/ruby-saml/logging.rb
|
79
|
+
- lib/onelogin/ruby-saml/logoutrequest.rb
|
112
80
|
- lib/onelogin/ruby-saml/metadata.rb
|
113
81
|
- lib/onelogin/ruby-saml/response.rb
|
114
82
|
- lib/onelogin/ruby-saml/settings.rb
|
115
83
|
- lib/onelogin/ruby-saml/validation_error.rb
|
116
84
|
- lib/onelogin/ruby-saml/version.rb
|
117
85
|
- lib/ruby-saml.rb
|
86
|
+
- lib/schemas/saml20assertion_schema.xsd
|
87
|
+
- lib/schemas/saml20protocol_schema.xsd
|
88
|
+
- lib/schemas/xenc_schema.xsd
|
89
|
+
- lib/schemas/xmldsig_schema.xsd
|
118
90
|
- lib/xml_security.rb
|
119
91
|
- ruby-saml.gemspec
|
120
92
|
- test/certificates/certificate1
|
93
|
+
- test/logoutrequest_test.rb
|
121
94
|
- test/request_test.rb
|
122
95
|
- test/response_test.rb
|
123
|
-
- test/responses/
|
96
|
+
- test/responses/adfs_response_sha1.xml
|
97
|
+
- test/responses/adfs_response_sha256.xml
|
98
|
+
- test/responses/adfs_response_sha384.xml
|
99
|
+
- test/responses/adfs_response_sha512.xml
|
100
|
+
- test/responses/no_signature_ns.xml
|
124
101
|
- test/responses/open_saml_response.xml
|
125
102
|
- test/responses/response1.xml.base64
|
126
103
|
- test/responses/response2.xml.base64
|
@@ -134,45 +111,41 @@ files:
|
|
134
111
|
- test/settings_test.rb
|
135
112
|
- test/test_helper.rb
|
136
113
|
- test/xml_security_test.rb
|
137
|
-
has_rdoc: true
|
138
114
|
homepage: http://github.com/onelogin/ruby-saml
|
139
115
|
licenses: []
|
140
|
-
|
141
116
|
post_install_message:
|
142
|
-
rdoc_options:
|
117
|
+
rdoc_options:
|
143
118
|
- --charset=UTF-8
|
144
|
-
require_paths:
|
119
|
+
require_paths:
|
145
120
|
- lib
|
146
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
122
|
none: false
|
148
|
-
requirements:
|
149
|
-
- -
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
|
152
|
-
|
153
|
-
- 0
|
154
|
-
version: "0"
|
155
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ! '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
128
|
none: false
|
157
|
-
requirements:
|
158
|
-
- -
|
159
|
-
- !ruby/object:Gem::Version
|
160
|
-
|
161
|
-
segments:
|
162
|
-
- 0
|
163
|
-
version: "0"
|
129
|
+
requirements:
|
130
|
+
- - ! '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
164
133
|
requirements: []
|
165
|
-
|
166
134
|
rubyforge_project: http://www.rubygems.org/gems/ruby-saml
|
167
|
-
rubygems_version: 1.
|
135
|
+
rubygems_version: 1.8.24
|
168
136
|
signing_key:
|
169
137
|
specification_version: 3
|
170
138
|
summary: SAML Ruby Tookit
|
171
|
-
test_files:
|
139
|
+
test_files:
|
172
140
|
- test/certificates/certificate1
|
141
|
+
- test/logoutrequest_test.rb
|
173
142
|
- test/request_test.rb
|
174
143
|
- test/response_test.rb
|
175
|
-
- test/responses/
|
144
|
+
- test/responses/adfs_response_sha1.xml
|
145
|
+
- test/responses/adfs_response_sha256.xml
|
146
|
+
- test/responses/adfs_response_sha384.xml
|
147
|
+
- test/responses/adfs_response_sha512.xml
|
148
|
+
- test/responses/no_signature_ns.xml
|
176
149
|
- test/responses/open_saml_response.xml
|
177
150
|
- test/responses/response1.xml.base64
|
178
151
|
- test/responses/response2.xml.base64
|
@@ -186,3 +159,4 @@ test_files:
|
|
186
159
|
- test/settings_test.rb
|
187
160
|
- test/test_helper.rb
|
188
161
|
- test/xml_security_test.rb
|
162
|
+
has_rdoc:
|