Module: RailsWebhookOutbox::Signature

Defined in:
lib/rails_webhook_outbox/signature.rb

Class Method Summary collapse

Class Method Details

.header_value(payload, secret) ⇒ Object



9
10
11
12
# File 'lib/rails_webhook_outbox/signature.rb', line 9

def self.header_value(payload, secret)
  algorithm = RailsWebhookOutbox.config.signing_algorithm
  "#{algorithm}=#{sign(payload, secret, algorithm)}"
end

.sign(payload, secret, algorithm) ⇒ Object



5
6
7
# File 'lib/rails_webhook_outbox/signature.rb', line 5

def self.sign(payload, secret, algorithm)
  OpenSSL::HMAC.hexdigest(algorithm.to_s.upcase, secret, payload)
end