Skip to content

Instantly share code, notes, and snippets.

@jhollinger
Created November 23, 2015 17:17
Show Gist options
  • Save jhollinger/c41011417f729ffe5c5c to your computer and use it in GitHub Desktop.
Save jhollinger/c41011417f729ffe5c5c to your computer and use it in GitHub Desktop.
Fix for Sidkiq::Web's lack of CSRF token
require 'securerandom'
module Sidekiq
class CsrfTokenFix
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
request.session[:csrf] ||= SecureRandom.base64(32)
@app.call(env)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment