samlsso 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4726e197c2a864889bce4358e93bdd5b7df30fb
4
- data.tar.gz: 11171ba18c677689f9eb6a872c61a16760de99a4
3
+ metadata.gz: 2c479c3d00dab26b27abac39e977a53d0f00d94f
4
+ data.tar.gz: c7a702cbac650ccda58721c97d5ab74731b8bf49
5
5
  SHA512:
6
- metadata.gz: f9025569164d30991dbcc92a68b14ac1b3039a13f196947c4bb55b191a9a1480d6fbefe3bba859f2aa0fd3bd9df660111814da9d6c39cf3cb73deb0726e2e9ea
7
- data.tar.gz: 506f296e5c1d651bec2ed9dcabad771ba231d27baea38700fd0873256ca537c365263fff569c6c81225dd3c3d7ed75ad65c29383e426f03775878189b27fffa6
6
+ metadata.gz: 0be017698f649229731f2787dfedfcfb0e8f0935096ffddf998d7920e51871158882acde73dcac1b4a575a3b3b61e06da6bd70fa42221fe4e0290048244bd328
7
+ data.tar.gz: 1b3308dac45366ede2aacafaea28ebc19ec17bd9c7ca0e1cecc9a2d3e958b73e5902669db5351383be6abae3bcbe6e8fe05e83affe48d30be0f2fc37169c11a7
@@ -1,3 +1,3 @@
1
1
  module Samlsso
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/xml_security.rb CHANGED
@@ -208,7 +208,8 @@ module XMLSecurity
208
208
  end
209
209
 
210
210
  # verify signature
211
- signed_info_element = REXML::XPath.first(@sig_element, "//ds:SignedInfo", {"ds"=>DSIG})
211
+ signed_info_element = REXML::XPath.first(@sig_element, "//ds:SignedInfo", {"ds"=>DSIG})
212
+ signed_info_element = REXML::XPath.first(@sig_element, "//ds:SignedInfo") unless signed_info_element
212
213
  noko_sig_element = document.at_xpath('//ds:Signature', 'ds' => DSIG)
213
214
  noko_signed_info_element = noko_sig_element.at_xpath('./ds:SignedInfo', 'ds' => DSIG)
214
215
  canon_algorithm = canon_algorithm REXML::XPath.first(@sig_element, '//ds:CanonicalizationMethod', 'ds' => DSIG)
@@ -216,7 +217,9 @@ module XMLSecurity
216
217
  noko_sig_element.remove
217
218
 
218
219
  # check digests
219
- REXML::XPath.each(@sig_element, "//ds:Reference", {"ds"=>DSIG}) do |ref|
220
+ tmp = REXML::XPath.each(@sig_element, "//ds:Reference", {"ds"=>DSIG})
221
+ tmp = REXML::XPath.each(@sig_element, "//ds:Reference") unless tmp.count > 0
222
+ tmp do |ref|
220
223
  uri = ref.attributes.get_attribute("URI").value
221
224
 
222
225
  hashed_element = document.at_xpath("//*[@ID='#{uri[1..-1]}']")
@@ -226,7 +229,10 @@ module XMLSecurity
226
229
  digest_algorithm = algorithm(REXML::XPath.first(ref, "//ds:DigestMethod", 'ds' => DSIG))
227
230
 
228
231
  hash = digest_algorithm.digest(canon_hashed_element)
229
- digest_value = Base64.decode64(REXML::XPath.first(ref, "//ds:DigestValue", {"ds"=>DSIG}).text)
232
+
233
+ base64_digest = REXML::XPath.first(ref, "//ds:DigestValue", {"ds"=>DSIG})
234
+ base64_digest = REXML::XPath.first(ref, "//ds:DigestValue") unless base64_digest
235
+ digest_value = Base64.decode64(base64_digest.text)
230
236
 
231
237
  unless digests_match?(hash, digest_value)
232
238
  @errors << "Digest mismatch"
@@ -234,15 +240,18 @@ module XMLSecurity
234
240
  end
235
241
  end
236
242
 
237
- base64_signature = REXML::XPath.first(@sig_element, "//ds:SignatureValue", {"ds"=>DSIG}).text
238
- signature = Base64.decode64(base64_signature)
243
+ base64_signature = REXML::XPath.first(@sig_element, "//ds:SignatureValue", {"ds"=>DSIG})
244
+ base64_signature = REXML::XPath.first(@sig_element, "//ds:SignatureValue") unless base64_signature
245
+ signature = Base64.decode64(base64_signature.text)
239
246
 
240
247
  # get certificate object
241
248
  cert_text = Base64.decode64(base64_cert)
242
249
  cert = OpenSSL::X509::Certificate.new(cert_text)
243
250
 
244
251
  # signature method
245
- signature_algorithm = algorithm(REXML::XPath.first(signed_info_element, "//ds:SignatureMethod", {"ds"=>DSIG}))
252
+ signature_method = REXML::XPath.first(signed_info_element, "//ds:SignatureMethod", {"ds"=>DSIG})
253
+ signature_method = REXML::XPath.first(signed_info_element, "//ds:SignatureMethod") unless signature_method
254
+ signature_algorithm = algorithm(signature_method)
246
255
 
247
256
  unless cert.public_key.verify(signature_algorithm.new, signature, canon_string)
248
257
  @errors << "Key validation error"
@@ -273,4 +282,4 @@ module XMLSecurity
273
282
  end
274
283
 
275
284
  end
276
- end
285
+ end
data/samlsso-0.1.4.gem ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: samlsso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siddhartha Mukherjee
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-23 00:00:00.000000000 Z
11
+ date: 2017-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uuid
@@ -139,6 +139,7 @@ files:
139
139
  - lib/schemas/xml.xsd
140
140
  - lib/schemas/xmldsig-core-schema.xsd
141
141
  - lib/xml_security.rb
142
+ - samlsso-0.1.4.gem
142
143
  - samlsso.gemspec
143
144
  homepage: https://github.com/siddhartham/samlsso
144
145
  licenses:
@@ -161,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
162
  version: '0'
162
163
  requirements: []
163
164
  rubyforge_project:
164
- rubygems_version: 2.5.1
165
+ rubygems_version: 2.2.2
165
166
  signing_key:
166
167
  specification_version: 4
167
168
  summary: SAML SSO for Ruby