github_webhook 0.1.1 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1180e1284554cb7a48aabf4eb9337844053516c6
4
- data.tar.gz: d955052b93e7897a7712a98cae94d6c6ffaf2ff7
3
+ metadata.gz: 285de73545052ef08df5f6196afbc7f8518c0623
4
+ data.tar.gz: 5cb6d51070167f9b52273bfef55bbd4f2a669240
5
5
  SHA512:
6
- metadata.gz: ffb54818c9769f28e8fefa0fda12211b585ab487593fb0a64f0e7fbe4410b79ab545da323f81263998b290b4d9bfa4b156ae3959d04aeca4642ecdbf39514c73
7
- data.tar.gz: 102a321a847b70380d8d76ba9e9785926457a80927ee5d050928b02d773d91ad0fceb8213768eff07e63b6393de46b89ca5376d5203ead9e2a33b54ece12899b
6
+ metadata.gz: 8fb9d9ab34f1938decb04a19e37229a1a0e614cea6857b419f9fabb0db2d4d979945276b7873165158433533a65510a729f18fed0311123e7a0c231c263e9de5
7
+ data.tar.gz: 7e64a43a655c9773cf524dd28783a0cb3967a0518d7439a8dbdd4a75e0e59c84b79aff9eeaaa5ce2d43fca0fac95f8f0725c3084e00c73bc9a1d9c398409c25c
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- github_webhook (0.1.0)
4
+ github_webhook (0.2.0)
5
5
  activesupport (~> 4)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (4.1.0)
10
+ activesupport (4.1.1)
11
11
  i18n (~> 0.6, >= 0.6.9)
12
12
  json (~> 1.7, >= 1.7.7)
13
13
  minitest (~> 5.1)
@@ -16,7 +16,7 @@ GEM
16
16
  diff-lcs (1.2.5)
17
17
  i18n (0.6.9)
18
18
  json (1.8.1)
19
- minitest (5.3.3)
19
+ minitest (5.3.5)
20
20
  rake (10.3.1)
21
21
  rspec (2.14.1)
22
22
  rspec-core (~> 2.14.0)
@@ -26,8 +26,8 @@ GEM
26
26
  rspec-expectations (2.14.5)
27
27
  diff-lcs (>= 1.1.3, < 2.0)
28
28
  rspec-mocks (2.14.6)
29
- thread_safe (0.3.3)
30
- tzinfo (1.1.0)
29
+ thread_safe (0.3.4)
30
+ tzinfo (1.2.1)
31
31
  thread_safe (~> 0.1)
32
32
 
33
33
  PLATFORMS
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
- [![Build Status](https://travis-ci.org/ssaunier/github_webhook.png)](https://travis-ci.org/ssaunier/github_webhook)
2
- [![Gem Version](https://badge.fury.io/rb/github_webhook.png)](http://badge.fury.io/rb/github_webhook)
1
+ [![Build Status](https://travis-ci.org/ssaunier/github_webhook.svg?branch=master)](https://travis-ci.org/ssaunier/github_webhook)
2
+ [![Gem Version](https://badge.fury.io/rb/github_webhook.svg)](http://badge.fury.io/rb/github_webhook)
3
3
 
4
4
 
5
5
  # GithubWebhook
@@ -34,11 +34,16 @@ Then create a new controller:
34
34
  # app/controllers/github_webhooks_controller.rb
35
35
  class GithubWebhooksController < ActionController::Base
36
36
  include GithubWebhook::Processor
37
- WEBHOOK_SECRET = ENV['GITHUB_WEBHOOK_SECRET']
38
37
 
39
38
  def push(payload)
40
39
  # TODO: handle push webhook
41
40
  end
41
+
42
+ private
43
+
44
+ def webhook_secret(payload)
45
+ ENV['GITHUB_WEBHOOK_SECRET']
46
+ end
42
47
  end
43
48
  ```
44
49
 
@@ -26,9 +26,10 @@ module GithubWebhook::Processor
26
26
  HMAC_DIGEST = OpenSSL::Digest.new('sha1')
27
27
 
28
28
  def authenticate_github_request!
29
- raise UnspecifiedWebhookSecretError.new unless defined?(self.class::WEBHOOK_SECRET)
29
+ raise UnspecifiedWebhookSecretError.new unless respond_to?(:webhook_secret)
30
+ secret = webhook_secret(json_body)
30
31
 
31
- expected_signature = "sha1=#{OpenSSL::HMAC.hexdigest(HMAC_DIGEST, self.class::WEBHOOK_SECRET, request_body)}"
32
+ expected_signature = "sha1=#{OpenSSL::HMAC.hexdigest(HMAC_DIGEST, secret, request_body)}"
32
33
  if signature_header != expected_signature
33
34
  raise SignatureError.new "Actual: #{signature_header}, Expected: #{expected_signature}"
34
35
  end
@@ -1,3 +1,3 @@
1
1
  module GithubWebhook
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -29,7 +29,9 @@ module GithubWebhook
29
29
  end
30
30
 
31
31
  class Controller < ControllerWithoutSecret
32
- WEBHOOK_SECRET = "secret"
32
+ def webhook_secret(payload)
33
+ "secret"
34
+ end
33
35
  end
34
36
 
35
37
  let(:controller) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_webhook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien Saunier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-25 00:00:00.000000000 Z
11
+ date: 2014-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport