【问题标题】:The page you requested was not found - Resubmit a form using csrf protection CI未找到您请求的页面 - 使用 csrf 保护 CI 重新提交表单
【发布时间】:2019-05-24 11:24:23
【问题描述】:

尝试手动重新加载表单时...出现 404 错误。
找不到您请求的页面 - 404

【问题讨论】:

  • 404 不是 CSRF 测试失败产生的错误。预期的错误是 403 并且消息“不允许您请求的操作。”

标签: codeigniter codeigniter-3 codeigniter-2


【解决方案1】:

你可以试试这个 - 扩展 MY_Securtiy 类并将页面重定向到referer。

create a file in application\core\MY_Security.php

/*  by Piku -trying to handle csrf resubmission error msg
 */

class MY_Security extends CI_Security {

    public function __construct()
    {
        parent::__construct();      
    }

    public function csrf_show_error()
    {
        header('Location: ' . htmlspecialchars($_SERVER['REQUEST_URI']), TRUE, 200);
    }
}

【讨论】:

  • 这是一个非常糟糕的答案,因为解决方案会使 CSRF 保护短路。
  • @DFriend 我尝试了上述答案及其工作......但如果答案不佳,请解释正确的方法......是否有其他方法可以做到这一点?
  • 答案的问题是它就像听到火警然后告诉所有人没有火然后关闭警报而不检查是否有火。无法解释如何解决问题,因为没有代码说明问题。
猜你喜欢
  • 1970-01-01
  • 2016-05-23
  • 1970-01-01
  • 2017-11-16
  • 1970-01-01
  • 2012-04-15
  • 2012-08-19
  • 1970-01-01
  • 2019-07-16
相关资源
最近更新 更多