module BearerRails::BearerInvoke::ClassMethods
Public Instance Methods
check_origin(origin)
click to toggle source
# File lib/bearer-rails/webhooks/bearer_invoke.rb, line 33 def check_origin(origin) end
check_sha(sha, body)
click to toggle source
# File lib/bearer-rails/webhooks/bearer_invoke.rb, line 28 def check_sha(sha, body) calculated_sha = OpenSSL::HMAC.hexdigest(digest, Bearer::Configuration.secret, body) throw "Signature invalid" if sha != calculated_sha end
digest()
click to toggle source
# File lib/bearer-rails/webhooks/bearer_invoke.rb, line 35 def digest @digest ||= OpenSSL::Digest.new("sha256") end
invoke(buid:, origin:, sha:, body:)
click to toggle source
# File lib/bearer-rails/webhooks/bearer_invoke.rb, line 15 def invoke(buid:, origin:, sha:, body:) check_sha(sha, body) check_origin(origin) records_to_invoke = BearerRails::Webhook.registry.select do |record| record[:handler] == buid end records_to_invoke.map do |record| record[:class].new(buid: buid, body: body).call end end