Class: MailgunWebhooks::Signature
- Inherits:
-
Object
- Object
- MailgunWebhooks::Signature
- Defined in:
- lib/mailgun_webhooks/signature.rb
Class Method Summary collapse
-
.valid?(data) ⇒ Boolean
Public: Verifies the incoming data according to the MailgunWebhooks specs: documentation.mailgun.net/user_manual.html#events-webhooks.
Class Method Details
.valid?(data) ⇒ Boolean
Public: Verifies the incoming data according to the MailgunWebhooks specs: documentation.mailgun.net/user_manual.html#events-webhooks
Returns a boolean.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mailgun_webhooks/signature.rb', line 9 def self.valid?(data) signature = data.fetch('signature') api_key = data.fetch('api_key') = data.fetch('timestamp') token = data.fetch('token') digest = OpenSSL::Digest.new('sha256') signature == OpenSSL::HMAC.hexdigest(digest, api_key, '%s%s' % [, token]) end |