CSRFトークンの検証プロセス

2012-04-12#rails

actionpack-3.2.2/lib/action_controller/metal/request_forgery_protection.rb

line:67

def protect_from_forgery(options = ) self.request_forgery_protection_token ||= :authenticity_token prepend_before_filter :verify_authenticity_token, options end

line:72

def verify_authenticity_token unless verified_request? logger.warn "WARNING: Can't verify CSRF token authenticity" if logger handle_unverified_request end end

line:84

def handle_unverified_request reset_session end

line:93

def verified_request? !protect_against_forgery? || request.get? || form_authenticity_token == params[request_forgery_protection_token] || form_authenticity_token == request.headers['X-CSRF-Token'] end

line:100

def form_authenticity_token session[:_csrf_token] ||= SecureRandom.base64(32) end