Class: Uploadcare::Param::WebhookSignatureVerifier
- Inherits:
-
Object
- Object
- Uploadcare::Param::WebhookSignatureVerifier
- Defined in:
- lib/uploadcare/param/webhook_signature_verifier.rb
Overview
This object verifies a signature received along with webhook headers
Class Method Summary collapse
Class Method Details
.valid?(options = {}) ⇒ Boolean
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/uploadcare/param/webhook_signature_verifier.rb', line 10 def self.valid?( = {}) webhook_body_json = [:webhook_body] signing_secret = [:signing_secret] || ENV.fetch('UC_SIGNING_SECRET', nil) x_uc_signature_header = [:x_uc_signature_header] digest = OpenSSL::Digest.new('sha256') calculated_signature = "v1=#{OpenSSL::HMAC.hexdigest(digest, signing_secret, webhook_body_json)}" calculated_signature == x_uc_signature_header end |