Module: Button::Utils
- Defined in:
- lib/button/utils.rb
Overview
Generally handy functions for various aspects of a Button integration
Class Method Summary collapse
-
.webhook_authentic?(webhook_secret, request_body, sent_signature) ⇒ Boolean
Used to verify that requests sent to a webhook endpoint are from Button and that their payload can be trusted.
Class Method Details
.webhook_authentic?(webhook_secret, request_body, sent_signature) ⇒ Boolean
Used to verify that requests sent to a webhook endpoint are from Button and that their payload can be trusted. Returns true if a webhook request body matches the sent signature and false otherwise.
11 12 13 14 15 16 17 18 19 |
# File 'lib/button/utils.rb', line 11 def webhook_authentic?(webhook_secret, request_body, sent_signature) computed_signature = OpenSSL::HMAC.hexdigest( OpenSSL::Digest.new('sha256'), webhook_secret, request_body ) sent_signature == computed_signature end |