Sha256: 6891026ed31b0d7748783f5c5714d3dc476c99c47bd910cb61203c3a7c15f96e
Contents?: true
Size: 1021 Bytes
Versions: 16
Compression:
Stored size: 1021 Bytes
Contents
# frozen_string_literal: true module ShopifyApp module AppProxyVerification extend ActiveSupport::Concern included do skip_before_action :verify_authenticity_token, raise: false before_action :verify_proxy_request end def verify_proxy_request return head(:forbidden) unless query_string_valid?(request.query_string) end private def query_string_valid?(query_string) query_hash = Rack::Utils.parse_query(query_string) signature = query_hash.delete("signature") return false if signature.nil? ActiveSupport::SecurityUtils.secure_compare( calculated_signature(query_hash), signature, ) end def calculated_signature(query_hash_without_signature) sorted_params = query_hash_without_signature.collect { |k, v| "#{k}=#{Array(v).join(",")}" }.sort.join OpenSSL::HMAC.hexdigest( OpenSSL::Digest.new("sha256"), ShopifyApp.configuration.secret, sorted_params, ) end end end
Version data entries
16 entries across 16 versions & 1 rubygems