Sha256: 51a384f3799697b2e981092d4a38ca5d5ceeb313ca273c67632d27aae0d2020a
Contents?: true
Size: 1.59 KB
Versions: 4
Compression:
Stored size: 1.59 KB
Contents
# typed: strict # frozen_string_literal: true module Authable extend T::Sig include ActionDispatch::Http::Cache::Response include ActionController::Helpers::ClassMethods include ActionController::HttpAuthentication::Basic::ControllerMethods include BodyParameter::YettoParameters SHA256_DIGEST = OpenSSL::Digest.new("sha256") sig { void } def <%= plug_name %>_calling_back? state = params.fetch(:state, "") state = params.fetch(:state, "") state_obj = parse_state(state) nonce = state_obj.fetch(:nonce, "") return true if ActiveSupport::SecurityUtils.secure_compare(nonce, <%= upcase_plug_name %>_APP_NONCE) self.status = Hephaestus::HTTP::BAD_REQUEST_I self.response_body = ::Hephaestus::ErrorSerializer.format(Hephaestus::HTTP::BAD_REQUEST) end sig { void } def webhook_from_<%= plug_name %>? # TODO: do whatever needs to be done to ensure that the webhook is coming from <%= plug_name %> # github_header = request.headers[::Constants::GITHUB_HTTP_X_HUB_SIGNATURE_256_HEADER] # if github_header.blank? # self.status = Hephaestus::HTTP::NOT_FOUND_I # self.response_body = ::Hephaestus::ErrorSerializer.format(Hephaestus::HTTP::NOT_FOUND) # return false # end # body = request.body.read # signature = "sha256=#{OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha256"), GITHUB_SECRET_TOKEN, body)}" # return true if Rack::Utils.secure_compare(signature, github_header) # self.status = Hephaestus::HTTP::BAD_REQUEST_I # self.response_body = ::Hephaestus::ErrorSerializer.format(Hephaestus::HTTP::BAD_REQUEST) end end
Version data entries
4 entries across 4 versions & 1 rubygems