Skip to content

Instantly share code, notes, and snippets.

@jhollinger
Created November 23, 2015 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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