bookingsync_application 0.4.0 → 0.4.1

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: d0697e1d6620be8da3f34c424aa2da55dd8496e8
4
- data.tar.gz: 735aeb9b1b2d0115cdaa1fdcefd7b1cdbf596969
3
+ metadata.gz: db3882b8207bb164374f0b62f6daed2eb8c43887
4
+ data.tar.gz: 571170a81a8c6434adc8e55436f37729fcadf7b4
5
5
  SHA512:
6
- metadata.gz: a39078ba5b1c687d41aad25814e790c31941515b2bbbaccd5b11d9794038f237ffdb5e11ff77e3b26ad6257968701402c86985213abdd12b0352e016e175541a
7
- data.tar.gz: d4b4adcab7f988bb16f4913f240eef0fea7c24178e26173827ee97576e285cffc4334e09f9ff7b5a897399611bf401ab9ac36989e91c5f5ec73ca21c751c2e66
6
+ metadata.gz: b03b0499dffd2543b8c09852899a0055c354c4ad79c1140529f80cc2da2c938b856d114b8ad2105e1553d34ec0ca08637b5505831fed6d47c9a536aa5f51241b
7
+ data.tar.gz: d1c50083935102e473361dad2f49d8dafbee2d4d7da17de23a43dc2ca356b37daa98a865f0e040de7f8c461923e3f9602298215db837efe978686c56573278e3
@@ -0,0 +1,40 @@
1
+ class BookingsyncApplication::Webhooks::BaseController < ApplicationController
2
+ skip_before_action :verify_authenticity_token
3
+ before_action :verify_signature
4
+
5
+ protected
6
+
7
+ def invalidate_request_and_log(message)
8
+ logger.info "Failing with 422 because: #{message}"
9
+ head 422
10
+ end
11
+
12
+ def verify_signature
13
+ Rails.logger.debug "bookingsync_hook_raw_post: #{request.raw_post}"
14
+ unless [old_signature, new_signature].include? request.headers["X-Content-Signature"]
15
+ invalidate_request_and_log "Bad BookingSync signature"
16
+ end
17
+ end
18
+
19
+ def old_signature
20
+ OpenSSL::HMAC.hexdigest(digest, ENV["BOOKINGSYNC_APP_SECRET"],
21
+ base64_encoded_payload)
22
+ end
23
+
24
+ def new_signature
25
+ OpenSSL::HMAC.hexdigest(digest, ENV["BOOKINGSYNC_APP_SECRET"],
26
+ base64_strict_encoded_payload)
27
+ end
28
+
29
+ def digest
30
+ OpenSSL::Digest.new("sha1")
31
+ end
32
+
33
+ def base64_encoded_payload
34
+ Base64.encode64(request.raw_post)
35
+ end
36
+
37
+ def base64_strict_encoded_payload
38
+ Base64.strict_encode64(request.raw_post)
39
+ end
40
+ end
@@ -1,3 +1,3 @@
1
1
  module BookingsyncApplication
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookingsync_application
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Nowicki
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-02-02 00:00:00.000000000 Z
13
+ date: 2016-02-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -191,6 +191,7 @@ files:
191
191
  - README.md
192
192
  - Rakefile
193
193
  - app/controllers/bookingsync_application/admin/base_controller.rb
194
+ - app/controllers/bookingsync_application/webhooks/base_controller.rb
194
195
  - config/routes.rb
195
196
  - lib/bookingsync_application.rb
196
197
  - lib/bookingsync_application/admin/common_base_controller.rb
@@ -223,3 +224,4 @@ signing_key:
223
224
  specification_version: 4
224
225
  summary: A Rails engine to simplify building BookingSync Applications
225
226
  test_files: []
227
+ has_rdoc: