class SiteHook::Server
Constants
- APPLICATION_JSON
Public Class Methods
verified?(body, sig, secret, plaintext:, service:)
click to toggle source
@param [String] body JSON String
of body @param [String] sig Signature or token from git service @param [String] secret User-defined verification token @param [Boolean] plaintext Whether the verification is plaintext @param [String] service service name
# File lib/site_hook/webhook.rb, line 27 def self.verified?(body, sig, secret, plaintext:, service:) if plaintext sig == secret else case service when 'gogs' if sig == OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new, secret, body.chomp) SiteHook::Log.app.debug "Secret verified: #{sig} === #{OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new, secret, body)}" true end when 'github' if sig == OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, secret, body.chomp) SiteHook::Log.app.debug "Secret verified: #{sig} === #{OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, secret, body)}" true end else # This shouldn't happen end end end
Public Instance Methods
halt(status, message, headers)
click to toggle source
# File lib/site_hook/webhook.rb, line 49 def halt(status, message, headers) error!(message, status, headers) end