Class: Urlbox::WebhookValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/urlbox/webhook_validator.rb

Constant Summary collapse

SIGNATURE_REGEX =
/^sha256=[0-9a-zA-Z]{40,}$/.freeze
TIMESTAMP_REGEX =
/^t=[0-9]+$/.freeze
WEBHOOK_AGE_MAX_MINUTES =
5

Class Method Summary collapse

Class Method Details

.call(header_signature, payload, webhook_secret) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/urlbox/webhook_validator.rb', line 10

def call(header_signature, payload, webhook_secret)
  timestamp, signature = header_signature.split(',')

  check_timestamp(timestamp)
  check_signature(signature, timestamp, payload, webhook_secret)

  true
end