rails中的csrf保护实际上是这样的
如果csrf验证没通过会调用一个方法
def verify_authenticity_token
unless verified_request?
logger.warn "WARNING: Can't verify CSRF token authenticity" if logger
handle_unverified_request
end
end
而handle_unverified_request这个方法是
def handle_unverified_request
reset_session
end
也就是说 如果csrf验证没过 它只是清除了cookie 通过这个方法使攻击者无法再利用cookie继续进一步的操作
但是对于cookie无关的操作 csrf没什么用
不过说到底csrf攻击主要还是跨站利用cookie 不需要cookie认证的操作 csrf自然是不需要保护的