integrallis / stripe_event

Stripe webhook integration for Rails applications.
https://rubygems.org/gems/stripe_event
MIT License
844 stars 104 forks source link

WebhookController produces an exception in Rails 5.2+ #115

Open gytdau opened 6 years ago

gytdau commented 6 years ago

When running the Rails app in production, the WebhookController errors: Before process_action callback :verify_authenticity_token has not been defined

As far as I can tell, this occurs in Rails 5.2 and up, since new configuration defaults were added, particularly this one:

# Add default protection from forgery to ActionController::Base instead of in
# ApplicationController.
Rails.application.config.action_controller.default_protect_from_forgery = true

which causes this if statement to be triggered in WebhookController:

if Rails.application.config.action_controller.default_protect_from_forgery
      skip_before_action :verify_authenticity_token
end

I'd try to make a pull request but I'm not sure what would fix this.

rmm5t commented 6 years ago

@gytdau Please do investigate. For reference, here's the PR that added this (specifically to support Rails 5.2): https://github.com/integrallis/stripe_event/pull/107/files

More background: