]> cat aescling's git repositories - mastodon.git/commitdiff
Suppress CSRF token warnings (#6240)
authorPatrick Figel <patrick@figel.email>
Mon, 15 Jan 2018 05:51:23 +0000 (06:51 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Mon, 15 Jan 2018 05:51:23 +0000 (06:51 +0100)
CSRF token checking was enabled for API controllers in #6223,
producing "Can't verify CSRF token authenticity" log spam. This
disables logging of failed CSRF checks.

This also changes the protection strategy for
PushSubscriptionsController to use exceptions, making it consistent
with other controllers that use sessions.

app/controllers/api/web/push_subscriptions_controller.rb
config/initializers/suppress_csrf_warnings.rb [new file with mode: 0644]

index 52e250d02da9708234db0b2b6090ce129ef38bdb..68ccbd5e20db006f5a42db880aa08c0a415d8435 100644 (file)
@@ -4,6 +4,7 @@ class Api::Web::PushSubscriptionsController < Api::BaseController
   respond_to :json
 
   before_action :require_user!
+  protect_from_forgery with: :exception
 
   def create
     params.require(:subscription).require(:endpoint)
diff --git a/config/initializers/suppress_csrf_warnings.rb b/config/initializers/suppress_csrf_warnings.rb
new file mode 100644 (file)
index 0000000..410ab58
--- /dev/null
@@ -0,0 +1,3 @@
+# frozen_string_literal: true
+
+ActionController::Base.log_warning_on_csrf_failure = false