class Clicksign::Webhooks::HMAC

Public Instance Methods

data() click to toggle source
# File lib/clicksign/webhooks/hmac.rb, line 16
def data
  @data = request.body.read
end
digest() click to toggle source
# File lib/clicksign/webhooks/hmac.rb, line 12
def digest
  @digest = OpenSSL::Digest::SHA256.new
end
hmac() click to toggle source
# File lib/clicksign/webhooks/hmac.rb, line 20
def hmac
  @hmac = OpenSSL::HMAC.hexdigest(digest, ENV['CLICKSIGN_HMAC_KEY'], data)
end
hmac_header() click to toggle source
# File lib/clicksign/webhooks/hmac.rb, line 24
def hmac_header
  @hmac_header = request.headers['Content-Hmac'] || ''
end
valid?() click to toggle source
# File lib/clicksign/webhooks/hmac.rb, line 8
def valid?
  hmac_header.include?(hmac)
end
validate!() click to toggle source
# File lib/clicksign/webhooks/hmac.rb, line 4
def validate!
  raise InvalidHMACError unless valid?
end