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"