ruby-saml 0.7.1 → 0.7.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.

@@ -34,7 +34,7 @@ module Onelogin
34
34
 
35
35
  def create_authentication_xml_doc(settings)
36
36
  uuid = "_" + UUID.new.generate
37
- time = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S")
37
+ time = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ")
38
38
  # Create AuthnRequest root element using REXML
39
39
  request_doc = REXML::Document.new
40
40
 
@@ -42,6 +42,7 @@ module Onelogin
42
42
  root.attributes['ID'] = uuid
43
43
  root.attributes['IssueInstant'] = time
44
44
  root.attributes['Version'] = "2.0"
45
+ root.attributes['Destination'] = settings.idp_sso_target_url unless settings.idp_sso_target_url.nil?
45
46
 
46
47
  # Conditionally defined elements based on settings
47
48
  if settings.assertion_consumer_service_url != nil
@@ -1,5 +1,5 @@
1
1
  module Onelogin
2
2
  module Saml
3
- VERSION = '0.7.1'
3
+ VERSION = '0.7.2'
4
4
  end
5
5
  end
@@ -37,7 +37,7 @@ module XMLSecurity
37
37
  C14N = "http://www.w3.org/2001/10/xml-exc-c14n#"
38
38
  DSIG = "http://www.w3.org/2000/09/xmldsig#"
39
39
 
40
- attr_accessor :signed_element_id, :sig_element, :noko_sig_element
40
+ attr_accessor :signed_element_id
41
41
 
42
42
  def initialize(response)
43
43
  super(response)
@@ -69,23 +69,26 @@ module XMLSecurity
69
69
 
70
70
  document = Nokogiri.parse(self.to_s)
71
71
 
72
+ # create a working copy so we don't modify the original
73
+ @working_copy ||= REXML::Document.new(self.to_s).root
74
+
72
75
  # store and remove signature node
73
- self.sig_element ||= begin
74
- element = REXML::XPath.first(self, "//ds:Signature", {"ds"=>DSIG})
76
+ @sig_element ||= begin
77
+ element = REXML::XPath.first(@working_copy, "//ds:Signature", {"ds"=>DSIG})
75
78
  element.remove
76
79
  end
77
80
 
78
81
 
79
82
  # verify signature
80
- signed_info_element = REXML::XPath.first(sig_element, "//ds:SignedInfo", {"ds"=>DSIG})
81
- self.noko_sig_element ||= document.at_xpath('//ds:Signature', 'ds' => DSIG)
83
+ signed_info_element = REXML::XPath.first(@sig_element, "//ds:SignedInfo", {"ds"=>DSIG})
84
+ noko_sig_element = document.at_xpath('//ds:Signature', 'ds' => DSIG)
82
85
  noko_signed_info_element = noko_sig_element.at_xpath('./ds:SignedInfo', 'ds' => DSIG)
83
- canon_algorithm = canon_algorithm REXML::XPath.first(sig_element, '//ds:CanonicalizationMethod', 'ds' => DSIG)
86
+ canon_algorithm = canon_algorithm REXML::XPath.first(@sig_element, '//ds:CanonicalizationMethod', 'ds' => DSIG)
84
87
  canon_string = noko_signed_info_element.canonicalize(canon_algorithm)
85
88
  noko_sig_element.remove
86
89
 
87
90
  # check digests
88
- REXML::XPath.each(sig_element, "//ds:Reference", {"ds"=>DSIG}) do |ref|
91
+ REXML::XPath.each(@sig_element, "//ds:Reference", {"ds"=>DSIG}) do |ref|
89
92
  uri = ref.attributes.get_attribute("URI").value
90
93
 
91
94
  hashed_element = document.at_xpath("//*[@ID='#{uri[1..-1]}']")
@@ -102,7 +105,7 @@ module XMLSecurity
102
105
  end
103
106
  end
104
107
 
105
- base64_signature = REXML::XPath.first(sig_element, "//ds:SignatureValue", {"ds"=>DSIG}).text
108
+ base64_signature = REXML::XPath.first(@sig_element, "//ds:SignatureValue", {"ds"=>DSIG}).text
106
109
  signature = Base64.decode64(base64_signature)
107
110
 
108
111
  # get certificate object
@@ -19,6 +19,21 @@ class RequestTest < Test::Unit::TestCase
19
19
  assert_match /^<samlp:AuthnRequest/, inflated
20
20
  end
21
21
 
22
+ should "create the deflated SAMLRequest URL parameter including the Destination" do
23
+ settings = Onelogin::Saml::Settings.new
24
+ settings.idp_sso_target_url = "http://example.com"
25
+ auth_url = Onelogin::Saml::Authrequest.new.create(settings)
26
+ payload = CGI.unescape(auth_url.split("=").last)
27
+ decoded = Base64.decode64(payload)
28
+
29
+ zstream = Zlib::Inflate.new(-Zlib::MAX_WBITS)
30
+ inflated = zstream.inflate(decoded)
31
+ zstream.finish
32
+ zstream.close
33
+
34
+ assert_match /<samlp:AuthnRequest[^<]* Destination='http:\/\/example.com'/, inflated
35
+ end
36
+
22
37
  should "create the SAMLRequest URL parameter without deflating" do
23
38
  settings = Onelogin::Saml::Settings.new
24
39
  settings.compress_request = false
@@ -76,6 +76,25 @@ class RubySamlTest < Test::Unit::TestCase
76
76
  assert response.is_valid?
77
77
  end
78
78
 
79
+ should "should be idempotent when the response is initialized with invalid data" do
80
+ response = Onelogin::Saml::Response.new(response_document_4)
81
+ response.stubs(:conditions).returns(nil)
82
+ settings = Onelogin::Saml::Settings.new
83
+ response.settings = settings
84
+ assert !response.is_valid?
85
+ assert !response.is_valid?
86
+ end
87
+
88
+ should "should be idempotent when the response is initialized with valid data" do
89
+ response = Onelogin::Saml::Response.new(response_document_4)
90
+ response.stubs(:conditions).returns(nil)
91
+ settings = Onelogin::Saml::Settings.new
92
+ response.settings = settings
93
+ settings.idp_cert_fingerprint = signature_fingerprint_1
94
+ assert response.is_valid?
95
+ assert response.is_valid?
96
+ end
97
+
79
98
  should "return true when using certificate instead of fingerprint" do
80
99
  response = Onelogin::Saml::Response.new(response_document_4)
81
100
  response.stubs(:conditions).returns(nil)
metadata CHANGED
@@ -1,78 +1,72 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ruby-saml
3
- version: !ruby/object:Gem::Version
4
- hash: 1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.2
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 7
9
- - 1
10
- version: 0.7.1
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
- date: 2013-01-23 00:00:00 -08:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2013-02-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: canonix
23
- prerelease: false
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
- hash: 25
30
- segments:
31
- - 0
32
- - 1
33
- - 1
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
34
21
  version: 0.1.1
35
22
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: uuid
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
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
41
33
  none: false
42
- requirements:
34
+ requirements:
43
35
  - - ~>
44
- - !ruby/object:Gem::Version
45
- hash: 5
46
- segments:
47
- - 2
48
- - 3
49
- version: "2.3"
36
+ - !ruby/object:Gem::Version
37
+ version: '2.3'
50
38
  type: :runtime
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: nokogiri
54
39
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
56
41
  none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- hash: 3
61
- segments:
62
- - 0
63
- version: "0"
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
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
64
54
  type: :runtime
65
- version_requirements: *id003
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
66
62
  description: SAML toolkit for Ruby on Rails
67
63
  email: support@onelogin.com
68
64
  executables: []
69
-
70
65
  extensions: []
71
-
72
- extra_rdoc_files:
66
+ extra_rdoc_files:
73
67
  - LICENSE
74
68
  - README.md
75
- files:
69
+ files:
76
70
  - .document
77
71
  - .gitignore
78
72
  - .travis.yml
@@ -121,41 +115,32 @@ files:
121
115
  - test/settings_test.rb
122
116
  - test/test_helper.rb
123
117
  - test/xml_security_test.rb
124
- has_rdoc: true
125
118
  homepage: http://github.com/onelogin/ruby-saml
126
119
  licenses: []
127
-
128
120
  post_install_message:
129
- rdoc_options:
121
+ rdoc_options:
130
122
  - --charset=UTF-8
131
- require_paths:
123
+ require_paths:
132
124
  - lib
133
- required_ruby_version: !ruby/object:Gem::Requirement
125
+ required_ruby_version: !ruby/object:Gem::Requirement
134
126
  none: false
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- hash: 3
139
- segments:
140
- - 0
141
- version: "0"
142
- required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
132
  none: false
144
- requirements:
145
- - - ">="
146
- - !ruby/object:Gem::Version
147
- hash: 3
148
- segments:
149
- - 0
150
- version: "0"
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
151
137
  requirements: []
152
-
153
138
  rubyforge_project: http://www.rubygems.org/gems/ruby-saml
154
- rubygems_version: 1.6.2
139
+ rubygems_version: 1.8.23
155
140
  signing_key:
156
141
  specification_version: 3
157
142
  summary: SAML Ruby Tookit
158
- test_files:
143
+ test_files:
159
144
  - test/certificates/certificate1
160
145
  - test/logoutrequest_test.rb
161
146
  - test/logoutresponse_test.rb
@@ -181,3 +166,4 @@ test_files:
181
166
  - test/settings_test.rb
182
167
  - test/test_helper.rb
183
168
  - test/xml_security_test.rb
169
+ has_rdoc: