1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Don't enable CSRF if sessions are disabled

This commit is contained in:
Mike Perham 2020-06-03 22:11:53 -07:00
parent eb2a6ab497
commit 3e26e06d06

View file

@ -155,12 +155,13 @@ module Sidekiq
def build_sessions
middlewares = self.middlewares
unless using?(CsrfProtection) || ENV["RACK_ENV"] == "test"
s = sessions
# turn on CSRF protection if sessions are enabled and this is not the test env
if s && !using?(CsrfProtection) && ENV["RACK_ENV"] != "test"
middlewares.unshift [[CsrfProtection], nil]
end
s = sessions
if s && !using?(::Rack::Session::Cookie)
unless (secret = Web.session_secret)
require "securerandom"