Adds CSRF protection to your Kemal application.
Requires a session middleware to be initialized first.
Add this to your application's
dependencies: kemal-csrf: github: kemalcr/kemal-csrf
require "kemal-csrf" add_handler CSRF.new
You can also change the name of the form field, header name, the methods which don't need csrf,error message and routes which you don't want csrf to apply. All of these are optional
require "kemal-csrf" add_handler CSRF.new( header: "X_CSRF_TOKEN", allowed_methods: ["GET", "HEAD", "OPTIONS", "TRACE"], allowed_routes: ["/api/somecallback"], parameter_name: "_csrf", error: "CSRF Error" )
- Fork it ( https://github.com/kemalcr/kemal-csrf/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- sdogruyol Serdar Dogruyol - creator, maintainer