rainforest_auth 0.0.8 → 0.0.9

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rainforest/auth.rb +11 -11
  3. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 092847008fd1864b58992f4df9957d9b2c6bcbb3
4
- data.tar.gz: 4bc7c147afc7fdeac2e819ac137f2a344d5d9d63
3
+ metadata.gz: 59e89bf38dee455ed6290f109d81693b0bd6fa47
4
+ data.tar.gz: a72007dd71e10ec92f00ebd690e829a46517b856
5
5
  SHA512:
6
- metadata.gz: d89a3ba05b33e5f960923b0c15f6732a35fee11d6c768e9e92acbea893766672c3a10b8c2f0fbc1461b267bc89aef99b1051437bc45ab1ed54355a93f4cb9fc5
7
- data.tar.gz: b7a810937312049491984a813f262d3136eadd6456968984eec1d680d6297b7f6a599f0a744f1f8eb389c70401744e1bff5184bf1d63e3472f79fe5d33d16a21
6
+ metadata.gz: 2011c1660738e280e539d28aafb4522718e0aa6a4fec84a19baf6e8bab03f58c2b673cbaaaaf7a2a39fce6c0ad483d9c432c67f0cdbea779b78a7c33b21577cf
7
+ data.tar.gz: 700a154486f9722a64a53ec802136aeb9e8dace2842f950f7aa137b106797a7401c739d15fbe76a07392986d7f25c8fc004694788d0df7af6c40a030974c42f0
@@ -3,7 +3,7 @@
3
3
  #
4
4
  #
5
5
  # @author Russell Smith <russ@rainforestqa.com>
6
- # @copyright CLDRDR Inc, 2013
6
+ # @copyright CLDRDR Inc, 2014
7
7
 
8
8
  require 'openssl'
9
9
  require 'json'
@@ -11,40 +11,40 @@ require 'json'
11
11
  class RainforestAuth
12
12
  attr_reader :key
13
13
 
14
- def initialize key
14
+ def initialize(key)
15
15
  @key = key
16
16
  self
17
17
  end
18
18
 
19
- def get_run_callback run_id, callback_type
19
+ def get_run_callback(run_id, callback_type)
20
20
  digest = sign(callback_type, {:run_id => run_id})
21
21
  "https://app.rainforestqa.com/api/1/callback/run/#{run_id}/#{callback_type}/#{digest}"
22
22
  end
23
23
 
24
24
  # Return a signature for a callback_type and specified options
25
- def sign callback_type, options = nil
25
+ def sign(callback_type, options = nil)
26
26
  OpenSSL::HMAC.hexdigest(digest, @key, merge_data(callback_type, options))
27
27
  end
28
28
 
29
29
  # Verify a digest vs callback_type and options
30
- def verify digest, callback_type, options = nil
30
+ def verify(digest, callback_type, options = nil)
31
31
  digest == sign(callback_type, options)
32
32
  end
33
33
 
34
34
  # Run a block if valid
35
- def run_if_valid digest, callback_type, options, &block
36
- if verify digest, callback_type, options
37
- block.call callback_type, options
35
+ def run_if_valid(digest, callback_type, options, &block)
36
+ if verify(digest, callback_type, options)
37
+ block.call(callback_type, options)
38
38
  end
39
39
  end
40
40
 
41
41
  private
42
42
 
43
43
  def digest
44
- OpenSSL::Digest::Digest.new 'sha1'
44
+ OpenSSL::Digest.new('sha1')
45
45
  end
46
46
 
47
- def merge_data callback_type, options
47
+ def merge_data(callback_type, options)
48
48
  {:callback_type => callback_type, :options => options}.to_json
49
49
  end
50
- end
50
+ end
metadata CHANGED
@@ -1,32 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rainforest_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Russell Smith
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain:
11
- - gem-public_cert.pem
12
- date: 2013-08-07 00:00:00.000000000 Z
10
+ cert_chain: []
11
+ date: 2014-02-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: json
16
15
  requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
- - - '>='
17
+ - - ">="
19
18
  - !ruby/object:Gem::Version
20
19
  version: '0'
21
20
  type: :runtime
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
- - - '>='
24
+ - - ">="
26
25
  - !ruby/object:Gem::Version
27
26
  version: '0'
28
27
  description: Signs / Authenticates messages
29
- email: russ@rainforestqa.com
28
+ email:
29
+ - russ@rainforestqa.com
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
@@ -41,17 +41,17 @@ require_paths:
41
41
  - lib
42
42
  required_ruby_version: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - '>='
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  required_rubygems_version: !ruby/object:Gem::Requirement
48
48
  requirements:
49
- - - '>='
49
+ - - ">="
50
50
  - !ruby/object:Gem::Version
51
51
  version: '0'
52
52
  requirements: []
53
53
  rubyforge_project:
54
- rubygems_version: 2.0.3
54
+ rubygems_version: 2.2.2
55
55
  signing_key:
56
56
  specification_version: 4
57
57
  summary: Authentication of messages for Rainforest webhooks