disco_app 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05c8aa89d8624265452b4a5f46c28579f90c4c985f5cbb38c0a256b9d9221d32
4
- data.tar.gz: a2ca5ed701971e55445170bb9796c94213d01a6c3f3ddc16cbe4a92c203bbb52
3
+ metadata.gz: d222fef3052055acefd393dca486ab68f5f7693d5a01cc30164a83808d9125c1
4
+ data.tar.gz: 515b778901873217f1932c63822031cde81c3f1efe1c1ec11d5c515c8128e3eb
5
5
  SHA512:
6
- metadata.gz: 1cef1ceb859bc5cfa9ebdb22d206426f714907b9c88d1f72d66869a61087b92c09112f41769b4893b26870615f9b522dfcdc821049c626d46e29531b15dbbc2a
7
- data.tar.gz: 308cf3007d6f16d8978d2ee8e0acbe447f9bc76674a235184d25aa6e7f8dc7a69673d1ad24d66e048ce9005c0d7d54a2f51fa68a3c3d44383e54b69a79c04ce5
6
+ metadata.gz: ceb9c5f888bab2694146b7585b7e6258dd32233fed4458b17c8d09fb6aa307bc2a5541ff0cfe8f74dba4695929ce4133467cd5e045aaf624146c3c51caf0865b
7
+ data.tar.gz: b2b5d1789bc7b4b61b8632316ec0dde497c9912609327ba379b43b727224cfc8f28f735ba929cbe8de8dfe72a3802fe0ee4a543aca7e70ba35ac726cb801622f
@@ -0,0 +1,32 @@
1
+ module DiscoApp
2
+ module CarrierRequestController
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ before_action :verify_carrier_request_signature
7
+ end
8
+
9
+ private
10
+
11
+ def verify_carrier_request_signature
12
+ unless carrier_request_signature_is_valid?
13
+ head :unauthorized
14
+ end
15
+ end
16
+
17
+ def carrier_request_signature_is_valid?
18
+ return true unless Rails.env.production?
19
+ data = request.body.read.to_s
20
+ hmac_header = request.headers['HTTP_X_SHOPIFY_HMAC_SHA256']
21
+ digest = OpenSSL::Digest::Digest.new('sha256')
22
+ calculated_hmac = Base64.encode64(OpenSSL::HMAC.digest(digest, ShopifyApp.configuration.secret, data)).strip
23
+ request.body.rewind
24
+ calculated_hmac == hmac_header
25
+ end
26
+
27
+ def carrier_request_domain
28
+ request.headers['HTTP_X_SHOPIFY_SHOP_DOMAIN']
29
+ end
30
+
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module DiscoApp
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disco_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Ballard
@@ -192,6 +192,7 @@ files:
192
192
  - app/assets/stylesheets/disco_app/disco_app.scss
193
193
  - app/controllers/disco_app/app_proxy_controller.rb
194
194
  - app/controllers/disco_app/authenticated_controller.rb
195
+ - app/controllers/disco_app/carrier_request_controller.rb
195
196
  - app/controllers/disco_app/charges_controller.rb
196
197
  - app/controllers/disco_app/install_controller.rb
197
198
  - app/controllers/disco_app/webhooks_controller.rb