A platform for community discussion. Free, open, simple.
FIX: Skip CSRF token check on webhook routes (#16982)
Wolftallemobe556ef17b71
diff --git a/app/controllers/webhooks_controller.rb b/app/controllers/webhooks_controller.rbindex 81f4a5d092e..e80dd92c667 100644--- a/app/controllers/webhooks_controller.rb+++ b/app/controllers/webhooks_controller.rb@@ -3,6 +3,7 @@require "openssl"class WebhooksController < ActionController::Base+ skip_before_action :verify_authenticity_tokendef mailgunreturn mailgun_failure if SiteSetting.mailgun_api_key.blank?diff --git a/spec/requests/webhooks_controller_spec.rb b/spec/requests/webhooks_controller_spec.rbindex 7100948a809..58e439ff1ef 100644--- a/spec/requests/webhooks_controller_spec.rb+++ b/spec/requests/webhooks_controller_spec.rb@@ -15,6 +15,11 @@ describe WebhooksController dobefore doSiteSetting.mailgun_api_key = "key-8221462f0c915af3f6f2e2df7aa5a493"+ ActionController::Base.allow_forgery_protection = true # Ensure the endpoint works, even with CSRF protection generally enabled+ end++ after do+ ActionController::Base.allow_forgery_protection = falseendit "works (deprecated)" do