class Rack::Protection::AuthenticityToken
- Prevented attack
-
CSRF
- Supported browsers
-
all
- More infos
Only accepts unsafe HTTP requests if a given access token matches the token included in the session.
Compatible with Rails and rack-csrf.
Public Instance Methods
accepts?(env)
click to toggle source
# File lib/rack/protection/authenticity_token.rb, line 15 def accepts?(env) return true if safe? env session = session env token = session[:csrf] ||= session['_csrf_token'] || random_string env['HTTP_X_CSRF_TOKEN'] == token or Request.new(env).params['authenticity_token'] == token end