CSRF保护码点火器



我可以在一页中为单个表单添加CSRF保护吗?

如果我在配置文件中生成$config['csrf_protection'] = TRUE;,那么它在应用程序中全局适用,但我不想全局生成。

有什么办法可以做到这一点吗?

我搜索了一下,没有找到任何解决方案。

我试过

$config['csrf_protection'] = FALSE;
$csrf = array(
'name' => $this->security->get_csrf_token_name(),
'hash' => $this->security->get_csrf_hash()
);
<input type="hidden" name="<?=$csrf['name'];?>" value="<?=$csrf['hash'];?>" />

我以前使用REQUEST_URI做过类似的事情,配置文件中的以下条件将起作用:

if (stripos($_SERVER["REQUEST_URI"],'/<path_for_which_you_want_enable_CSRF>/') === TRUE) 
{
$config['csrf_protection']  = TRUE;
} else
{ 
$config['csrf_protection']  = FALSE; 
}

最新更新