Sha256: 3e006701052408ea865431b95c56b1c077b915a36016a2527985d7a50d94ef1e
Contents?: true
Size: 785 Bytes
Versions: 17
Compression:
Stored size: 785 Bytes
Contents
module DiscoApp module CarrierRequestController extend ActiveSupport::Concern included do before_action :verify_carrier_request_signature end private def verify_carrier_request_signature unless carrier_request_signature_is_valid? head :unauthorized end end def carrier_request_signature_is_valid? return true unless Rails.env.production? data = request.body.read.to_s hmac_header = request.headers['HTTP_X_SHOPIFY_HMAC_SHA256'] digest = OpenSSL::Digest::Digest.new('sha256') calculated_hmac = Base64.encode64(OpenSSL::HMAC.digest(digest, ShopifyApp.configuration.secret, data)).strip request.body.rewind calculated_hmac == hmac_header end end end
Version data entries
17 entries across 17 versions & 1 rubygems