From 200c7a5ddac188d0b59139d988bd0d6dd173903a Mon Sep 17 00:00:00 2001 From: Danielius Visockas Date: Tue, 2 Apr 2019 14:26:45 +0300 Subject: [PATCH] Extend config with webhook_token --- lib/onfido/configuration.rb | 4 +++- lib/onfido/resources/webhook.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/onfido/configuration.rb b/lib/onfido/configuration.rb index 1ad3407..5b26483 100644 --- a/lib/onfido/configuration.rb +++ b/lib/onfido/configuration.rb @@ -4,7 +4,8 @@ module Configuration us: "api.us.onfido.com" }.freeze - attr_accessor :api_key, :region, :open_timeout, :read_timeout, :api_version + attr_accessor :api_key, :region, :open_timeout, :read_timeout, :api_version, + :webhook_token def self.extended(base) base.reset @@ -16,6 +17,7 @@ def configure def reset self.api_key = nil + self.webhook_token = nil self.region = nil self.open_timeout = 30 self.read_timeout = 80 diff --git a/lib/onfido/resources/webhook.rb b/lib/onfido/resources/webhook.rb index b43f08c..ddf57bf 100644 --- a/lib/onfido/resources/webhook.rb +++ b/lib/onfido/resources/webhook.rb @@ -18,7 +18,7 @@ def all(page: 1, per_page: 20) # As well as being a normal resource, Onfido::Webhook also supports # verifying the authenticity of a webhook by comparing the signature on the # request to one computed from the body - def self.valid?(request_body, request_signature, token) + def self.valid?(request_body, request_signature, token = Onfido.webhook_token) if [request_body, request_signature, token].any?(&:nil?) raise ArgumentError, "A request body, request signature and token " \ "must be provided"