Sha256: a038c81c7e7a5b087cd24317513e10f3d680c63665e881d088a5a22b4e30271e
Contents?: true
Size: 674 Bytes
Versions: 1
Compression:
Stored size: 674 Bytes
Contents
require 'rack/utils' module Github module Webhook class Auth def initialize app @app = app end def call env return [401, {}, ''] unless verify_signature(env.dup) @app.call env end private def verify_signature env Rack::Utils.secure_compare signature(body env), env.fetch('HTTP_X_HUB_SIGNATURE','') end def body env env['rack.input'].rewind env['rack.input'].read end def signature body 'sha1=' + OpenSSL::HMAC.hexdigest(digest, ENV['SECRET_TOKEN'], body) end def digest OpenSSL::Digest.new('sha1') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
github-webhook-auth-0.0.1 | lib/github/webhook/auth.rb |