class RightHook::App
Inherit from this class and implement the on_issue, on_pull_request, etc. methods to configure how you respond to GitHub hooks.
Public Instance Methods
secret(owner, repo_name, event_type)
click to toggle source
It is up to you to override secret to determine how to look up the correct secret for an owner/repo combo.
# File lib/right_hook/app.rb, line 39 def secret(owner, repo_name, event_type) raise NotImplementedError, "You didn't specify how to find the secret for a repo!" end
Private Instance Methods
require_valid_signature(content, owner, repo_name, event_type)
click to toggle source
# File lib/right_hook/app.rb, line 45 def require_valid_signature(content, owner, repo_name, event_type) s = secret(owner, repo_name, event_type) expected_signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new('sha1'), s, content) # http://pubsubhubbub.googlecode.com/git/pubsubhubbub-core-0.4.html#authednotify # "If the signature does not match, subscribers MUST still return a 2xx success response to acknowledge receipt, but locally ignore the message as invalid." received_signature = request.env['HTTP_X_HUB_SIGNATURE'] calculated_signature = "sha1=#{expected_signature}" halt 202, "Signature mismatch" unless received_signature == calculated_signature end