Sha256: 4c3bc1b7d687ef973520be4d38ea7b736daaeab99b781de53959d920e1dadea2
Contents?: true
Size: 622 Bytes
Versions: 8
Compression:
Stored size: 622 Bytes
Contents
module Whiplash class App module Signing def signature(body) sha256 = OpenSSL::Digest::SHA256.new OpenSSL::HMAC.hexdigest(sha256, ENV["WHIPLASH_CLIENT_SECRET"], request_body(body)) end def verified?(request) body = request.try(:body).try(:read) request.headers["X-WHIPLASH-SIGNATURE"] == signature(body) end private def request_body(body) begin (body.nil? || body.empty?) ? ENV["WHIPLASH_CLIENT_ID"] : body rescue NoMethodError => e ENV["WHIPLASH_CLIENT_ID"] end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems