caren-api 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/caren-api.gemspec +1 -1
  3. data/lib/caren/caren.rb +7 -4
  4. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.2
1
+ 0.9.3
data/caren-api.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "caren-api"
8
- s.version = "0.9.2"
8
+ s.version = "0.9.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andre Foeken"]
data/lib/caren/caren.rb CHANGED
@@ -192,8 +192,12 @@ module Caren
192
192
  # Verify the signature using the caren public key
193
193
  def verify_signature signature, timestamp, path, string=nil, public_key=self.caren_public_key
194
194
  return false unless public_key
195
- signature = Base64.decode64(CGI.unescape(signature.to_s))
196
- DIGEST_ALGORITHMS.map{ |algorithm| public_key.verify( algorithm, signature, "#{path}#{string}#{timestamp}".strip ) }.any?
195
+ verify_string(signature, "#{path}#{string}#{timestamp}", public_key)
196
+ end
197
+
198
+ def verify_string provided_string, expected_string, public_key=self.caren_public_key
199
+ provided_string = Base64.decode64(CGI.unescape(provided_string.to_s))
200
+ DIGEST_ALGORITHMS.map{ |algorithm| public_key.verify( algorithm, provided_string, expected_string.strip ) }.any?
197
201
  end
198
202
 
199
203
  def create_photo_signature url_shortcut, external_or_caren_id, private_key=self.private_key
@@ -204,8 +208,7 @@ module Caren
204
208
  # Verify photo url signature using the caren public key
205
209
  def verify_photo_signature signature, url_shortcut, external_id, public_key=self.caren_public_key
206
210
  return false unless public_key
207
- signature = Base64.decode64(CGI.unescape(signature.to_s))
208
- DIGEST_ALGORITHMS.map{ |algorithm| public_key.verify( algorithm, signature, url_shortcut.to_s + external_id.to_s ) }.any?
211
+ verify_string(signature, url_shortcut.to_s + external_id.to_s, public_key)
209
212
  end
210
213
 
211
214
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caren-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -269,7 +269,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
269
269
  version: '0'
270
270
  segments:
271
271
  - 0
272
- hash: -3122321847705514891
272
+ hash: 2880785186653608564
273
273
  required_rubygems_version: !ruby/object:Gem::Requirement
274
274
  none: false
275
275
  requirements: