fb_graph 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.0
1
+ 1.5.1
data/fb_graph.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fb_graph}
8
- s.version = "1.5.0"
8
+ s.version = "1.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["nov matake"]
@@ -1,5 +1,5 @@
1
1
  require 'base64'
2
- require 'hmac/sha2'
2
+ require 'openssl'
3
3
 
4
4
  module FbGraph
5
5
  class Auth
@@ -11,13 +11,18 @@ module FbGraph
11
11
  signature = base64_url_decode signature
12
12
  data = decode_json base64_url_decode(payload)
13
13
  raise VerificationFailed.new(401, 'Unexpected Signature Algorithm') unless data[:algorithm] == 'HMAC-SHA256'
14
- _signature_ = HMAC::SHA256.digest(client.secret, payload)
14
+ _signature_ = sign(client.secret, payload)
15
15
  raise VerificationFailed.new(401, 'Signature Invalid') unless signature == _signature_
16
16
  data
17
17
  end
18
18
 
19
19
  private
20
20
 
21
+ def self.sign(key, data)
22
+ klass = OpenSSL::Digest::SHA256.new
23
+ OpenSSL::HMAC.digest(klass, key, data)
24
+ end
25
+
21
26
  def self.decode_json(json)
22
27
  JSON.parse(json).with_indifferent_access
23
28
  rescue => e
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_graph
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 5
9
- - 0
10
- version: 1.5.0
9
+ - 1
10
+ version: 1.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - nov matake