Sha256: f3050084f6ea4aac05dc43d155f9a513c4391ef317f73c27dfd07a2601afc937

Contents?: true

Size: 776 Bytes

Versions: 31

Compression:

Stored size: 776 Bytes

Contents

require_dependency "hubstats/application_controller"

module Hubstats
  class EventsController < ApplicationController

    def handler
      verify_signature(request)

      kind = request.headers['X-Github-Event']
      event = params.with_indifferent_access
      eventsHandler = Hubstats::EventsHandler.new()
      eventsHandler.route(event,kind)

      render :nothing => true
    end

    private
    def verify_signature(request)
      request.body.rewind
      payload_body = request.body.read
      signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), Hubstats.config.webhook_endpoint, payload_body)
      return 500, "Signatures didn't match!" unless Rack::Utils.secure_compare(signature, request.env['HTTP_X_HUB_SIGNATURE'])
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
hubstats-0.3.17 app/controllers/hubstats/events_controller.rb
hubstats-0.3.16 app/controllers/hubstats/events_controller.rb
hubstats-0.3.15 app/controllers/hubstats/events_controller.rb
hubstats-0.3.14 app/controllers/hubstats/events_controller.rb
hubstats-0.3.13 app/controllers/hubstats/events_controller.rb
hubstats-0.3.12 app/controllers/hubstats/events_controller.rb
hubstats-0.3.11 app/controllers/hubstats/events_controller.rb
hubstats-0.3.10 app/controllers/hubstats/events_controller.rb
hubstats-0.3.9 app/controllers/hubstats/events_controller.rb
hubstats-0.3.8 app/controllers/hubstats/events_controller.rb
hubstats-0.3.7 app/controllers/hubstats/events_controller.rb
hubstats-0.3.6 app/controllers/hubstats/events_controller.rb
hubstats-0.3.5 app/controllers/hubstats/events_controller.rb
hubstats-0.3.4 app/controllers/hubstats/events_controller.rb
hubstats-0.3.3 app/controllers/hubstats/events_controller.rb
hubstats-0.3.2 app/controllers/hubstats/events_controller.rb
hubstats-0.3.1 app/controllers/hubstats/events_controller.rb
hubstats-0.3.0 app/controllers/hubstats/events_controller.rb
hubstats-0.2.3 app/controllers/hubstats/events_controller.rb
hubstats-0.2.2 app/controllers/hubstats/events_controller.rb