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 +4 -4
- data/app/controllers/disco_app/carrier_request_controller.rb +32 -0
- data/lib/disco_app/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d222fef3052055acefd393dca486ab68f5f7693d5a01cc30164a83808d9125c1
|
4
|
+
data.tar.gz: 515b778901873217f1932c63822031cde81c3f1efe1c1ec11d5c515c8128e3eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/disco_app/version.rb
CHANGED
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.
|
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
|