ruby-saml 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ruby-saml might be problematic. Click here for more details.
- data/.gitignore +5 -0
- data/VERSION +1 -1
- data/lib/onelogin/saml/response.rb +1 -2
- data/lib/{xml_sec.rb → xml_security.rb} +23 -23
- data/ruby-saml.gemspec +23 -19
- data/test/xml_security_test.rb +16 -0
- metadata +10 -7
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
@@ -28,7 +28,7 @@ require "rexml/xpath"
|
|
28
28
|
require "openssl"
|
29
29
|
require "xmlcanonicalizer"
|
30
30
|
require "digest/sha1"
|
31
|
-
|
31
|
+
|
32
32
|
module XMLSecurity
|
33
33
|
|
34
34
|
class SignedDocument < REXML::Document
|
@@ -38,54 +38,54 @@ module XMLSecurity
|
|
38
38
|
base64_cert = self.elements["//ds:X509Certificate"].text
|
39
39
|
cert_text = Base64.decode64(base64_cert)
|
40
40
|
cert = OpenSSL::X509::Certificate.new(cert_text)
|
41
|
-
|
41
|
+
|
42
42
|
# check cert matches registered idp cert
|
43
43
|
fingerprint = Digest::SHA1.hexdigest(cert.to_der)
|
44
44
|
valid_flag = fingerprint == idp_cert_fingerprint.gsub(":", "").downcase
|
45
|
-
|
46
|
-
return valid_flag if !valid_flag
|
47
|
-
|
45
|
+
|
46
|
+
return valid_flag if !valid_flag
|
47
|
+
|
48
48
|
validate_doc(base64_cert, logger)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
def validate_doc(base64_cert, logger)
|
52
52
|
# validate references
|
53
|
-
|
53
|
+
|
54
54
|
# remove signature node
|
55
|
-
sig_element = XPath.first(self, "//ds:Signature", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"})
|
55
|
+
sig_element = REXML::XPath.first(self, "//ds:Signature", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"})
|
56
56
|
sig_element.remove
|
57
|
-
|
57
|
+
|
58
58
|
#check digests
|
59
|
-
XPath.each(sig_element, "//ds:Reference", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"}) do | ref |
|
60
|
-
|
59
|
+
REXML::XPath.each(sig_element, "//ds:Reference", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"}) do | ref |
|
60
|
+
|
61
61
|
uri = ref.attributes.get_attribute("URI").value
|
62
|
-
hashed_element = XPath.first(self, "//[@ID='#{uri[1,uri.size]}']")
|
62
|
+
hashed_element = REXML::XPath.first(self, "//[@ID='#{uri[1,uri.size]}']")
|
63
63
|
canoner = XML::Util::XmlCanonicalizer.new(false, true)
|
64
64
|
canon_hashed_element = canoner.canonicalize(hashed_element)
|
65
65
|
hash = Base64.encode64(Digest::SHA1.digest(canon_hashed_element)).chomp
|
66
|
-
digest_value = XPath.first(ref, "//ds:DigestValue", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"}).text
|
67
|
-
|
68
|
-
valid_flag = hash == digest_value
|
69
|
-
|
66
|
+
digest_value = REXML::XPath.first(ref, "//ds:DigestValue", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"}).text
|
67
|
+
|
68
|
+
valid_flag = hash == digest_value
|
69
|
+
|
70
70
|
return valid_flag if !valid_flag
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
# verify signature
|
74
74
|
canoner = XML::Util::XmlCanonicalizer.new(false, true)
|
75
|
-
signed_info_element = XPath.first(sig_element, "//ds:SignedInfo", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"})
|
75
|
+
signed_info_element = REXML::XPath.first(sig_element, "//ds:SignedInfo", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"})
|
76
76
|
canon_string = canoner.canonicalize(signed_info_element)
|
77
77
|
|
78
|
-
base64_signature = XPath.first(sig_element, "//ds:SignatureValue", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"}).text
|
78
|
+
base64_signature = REXML::XPath.first(sig_element, "//ds:SignatureValue", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"}).text
|
79
79
|
signature = Base64.decode64(base64_signature)
|
80
|
-
|
80
|
+
|
81
81
|
# get certificate object
|
82
82
|
cert_text = Base64.decode64(base64_cert)
|
83
83
|
cert = OpenSSL::X509::Certificate.new(cert_text)
|
84
|
-
|
84
|
+
|
85
85
|
valid_flag = cert.public_key.verify(OpenSSL::Digest::SHA1.new, signature, canon_string)
|
86
|
-
|
86
|
+
|
87
87
|
return valid_flag
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
end
|
91
91
|
end
|
data/ruby-saml.gemspec
CHANGED
@@ -1,45 +1,49 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ruby-saml}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["OneLogin LLC"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-02-01}
|
13
13
|
s.description = %q{SAML toolkit for Ruby on Rails}
|
14
14
|
s.email = %q{support@onelogin.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/onelogin/saml.rb",
|
27
|
+
"lib/onelogin/saml/authrequest.rb",
|
28
|
+
"lib/onelogin/saml/response.rb",
|
29
|
+
"lib/onelogin/saml/settings.rb",
|
30
|
+
"lib/ruby-saml.rb",
|
31
|
+
"lib/xml_security.rb",
|
32
|
+
"ruby-saml.gemspec",
|
33
|
+
"test/response.txt",
|
34
|
+
"test/ruby-saml_test.rb",
|
35
|
+
"test/test_helper.rb",
|
36
|
+
"test/xml_security_test.rb"
|
35
37
|
]
|
36
38
|
s.homepage = %q{http://github.com/onelogin/ruby-saml}
|
39
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
37
40
|
s.require_paths = ["lib"]
|
38
41
|
s.rubygems_version = %q{1.3.7}
|
39
42
|
s.summary = %q{SAML Ruby Tookit}
|
40
43
|
s.test_files = [
|
41
44
|
"test/ruby-saml_test.rb",
|
42
|
-
|
45
|
+
"test/test_helper.rb",
|
46
|
+
"test/xml_security_test.rb"
|
43
47
|
]
|
44
48
|
|
45
49
|
if s.respond_to? :specification_version then
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'xml_security'
|
3
|
+
|
4
|
+
class XmlSecurityTest < Test::Unit::TestCase
|
5
|
+
include XMLSecurity
|
6
|
+
context "XmlSecurity" do
|
7
|
+
setup do
|
8
|
+
@document = XMLSecurity::SignedDocument.new(Base64.decode64(response_document))
|
9
|
+
end
|
10
|
+
|
11
|
+
should "should provide getters and settings" do
|
12
|
+
base64cert = @document.elements["//ds:X509Certificate"].text
|
13
|
+
@document.validate_doc(base64cert, nil)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-saml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- OneLogin LLC
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-02-01 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -89,6 +89,7 @@ extra_rdoc_files:
|
|
89
89
|
- README.rdoc
|
90
90
|
files:
|
91
91
|
- .document
|
92
|
+
- .gitignore
|
92
93
|
- LICENSE
|
93
94
|
- README.rdoc
|
94
95
|
- Rakefile
|
@@ -98,18 +99,19 @@ files:
|
|
98
99
|
- lib/onelogin/saml/response.rb
|
99
100
|
- lib/onelogin/saml/settings.rb
|
100
101
|
- lib/ruby-saml.rb
|
101
|
-
- lib/
|
102
|
+
- lib/xml_security.rb
|
102
103
|
- ruby-saml.gemspec
|
103
104
|
- test/response.txt
|
104
105
|
- test/ruby-saml_test.rb
|
105
106
|
- test/test_helper.rb
|
107
|
+
- test/xml_security_test.rb
|
106
108
|
has_rdoc: true
|
107
109
|
homepage: http://github.com/onelogin/ruby-saml
|
108
110
|
licenses: []
|
109
111
|
|
110
112
|
post_install_message:
|
111
|
-
rdoc_options:
|
112
|
-
|
113
|
+
rdoc_options:
|
114
|
+
- --charset=UTF-8
|
113
115
|
require_paths:
|
114
116
|
- lib
|
115
117
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -140,3 +142,4 @@ summary: SAML Ruby Tookit
|
|
140
142
|
test_files:
|
141
143
|
- test/ruby-saml_test.rb
|
142
144
|
- test/test_helper.rb
|
145
|
+
- test/xml_security_test.rb
|