Disable forgery protection for ReceiveController

This is enabled by default since rails 5.2, but it doesn't make sense
for the /receive/ routes, because they are called without a session and
without a token.
This commit is contained in:
Benjamin Neff 2022-07-23 01:57:12 +02:00
parent 15465bf46a
commit 8a8678c97b
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
2 changed files with 7 additions and 1 deletions

View file

@ -5,6 +5,8 @@ require_dependency "diaspora_federation/application_controller"
module DiasporaFederation
# This controller processes receiving messages.
class ReceiveController < ApplicationController
skip_forgery_protection
# Receives public messages
#
# POST /receive/public

View file

@ -50,7 +50,11 @@ RSpec.configure do |config|
expect_config.syntax = :expect
end
unless defined?(::Rails)
if defined?(::Rails)
config.before(:each, type: :controller) do
ActionController::Base.allow_forgery_protection = true
end
else
config.exclude_pattern = "**/controllers/**/*_spec.rb, **/routing/**/*_spec.rb"
config.filter_run_excluding rails: true
end