class Rack::CsrfDetector
Public Class Methods
more_bad!()
click to toggle source
# File lib/rack/csrf_detector.rb, line 31 def self.more_bad! @@bad_count += 1 end
new(app, opts={}, &block)
click to toggle source
# File lib/rack/csrf_detector.rb, line 5 def initialize(app, opts={}, &block) @app = app require 'rack/csrf_detector/active_record_instrument' require 'rack/csrf_detector/sidekiq_instrument' if block_given? if block.arity == 1 block.call(self) else instance_eval(&block) end end end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/csrf_detector.rb, line 20 def call(env) @@bad_count = 0 status, headers, response = @app.call(env) if env['REQUEST_METHOD'] == 'GET' && @@bad_count > 0 headers["CSRF_WARNING"] = 'yes' end [status, headers, response] end
Private Instance Methods
use(klass)
click to toggle source
# File lib/rack/csrf_detector.rb, line 37 def use(klass) klass.new.use! end