shadowprince / forman-csrf
shadowprince/forman 的 CSRF 保护插件
0.1
2013-10-24 18:30 UTC
Requires
- php: >=5.2.0
- shadowprince/forman: >=0.2
This package is not auto-updated.
Last update: 2024-09-24 04:54:38 UTC
README
Forman-Recaptcha - for forman 的插件,为所有表单添加自动 CSRF 保护。插件在后台运行,无需代码。
机制
- 在每次表单
process
时生成并存储令牌 - 比较来自表单数据和用户 cookies 的令牌,如果 cookie 不存在或不匹配,则添加字段错误并
verify
(因此process
也失败) - 从
process
结果中删除csrf_token
,所以您甚至不会注意到
您可以关闭单个表单的该功能
\Forman\CSRFPlugin::disable(); if ($data = $form->process($_POST)) { // now there is no CSRF } \Forman\CSRFPlugin::enable();
或全局
// somewhere in bootstrap \Forman\CSRFPlugin::disableGlobal(); // so any enable() will not work now