Skip to content

tam7t/rack-csrf-detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rack-csrf-detector

Rails only protects you against CSRFs if you use GET and POST correctly. This middleware helps you identify when a GET request results in an application state-change.

How It Works

rack-csrf-detector monkey-patches ActiveRecord to identify GET requests that cause a database commit. A CRSF-WARNING header is added to responses when this is detected. An accompanying chrome extension is available to alert when the header is present.

Usage

Add the following to your Gemfile

gem 'rack-csrf-detector', :require => 'rack/csrf_detector'

And include the middleware in your development.rb

config.middleware.use "Rack::CsrfDetector" do
  use Rack::CsrfDetector::ActiveRecordInstrument
  use Rack::CsrfDetector::SidekiqInstrument
end

Note: Do not run this in production.

You can also install the chrome extension:

More Tools | Extensions | Developer mode | Load Unpacked extension...

And select the chrome-extension folder in this repo.

About

Automated CSRF detection middleware

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published