Sha256: 88a060c24659e2c88e08b7e968ba8c0946e17094ba23bb13e89737ffdd45c366
Contents?: true
Size: 582 Bytes
Versions: 10
Compression:
Stored size: 582 Bytes
Contents
require "json" require "openssl" module Onfido class OnfidoInvalidSignatureError < StandardError; end class WebhookEventVerifier def initialize(webhook_token) @webhook_token = webhook_token end def read_payload(event_body, signature) event_signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), @webhook_token, event_body) raise(OnfidoInvalidSignatureError, "Invalid signature for webhook event") unless OpenSSL.secure_compare(signature, event_signature) WebhookEvent.build_from_hash(JSON.parse(event_body)) end end end
Version data entries
10 entries across 10 versions & 1 rubygems