【问题标题】:How can I disable cakephp security?如何禁用 cakephp 安全性?
【发布时间】:2013-05-21 17:31:26
【问题描述】:

我用过

public function beforeFilter() {
    parent::beforeFilter();
    $this->Security->validatePost = false;
    $this->Security->csrfCheck = false;
    $this->Security->unlockedActions = array('my_action');
}

但它不起作用,仍然报告

Security Error
The requested address was not found on this server.

Request blackholed due to "auth" violation.

我记得它工作正常,我可以发布我的数据,但它突然停止了。我不确定会发生什么并尝试我的所有搜索结果,但它不起作用。如何停止 CakePHP 中的安全组件?

我什至使用

public function beforeFilter() {
    parent::beforeFilter();
    $this->Components->disable('Security');
}

【问题讨论】:

  • 只需从控制器中删除 public $components = array('Security'); 部分。因此,只需停止在您的应用中实现它即可调试问题的根源:)
  • 我没有 public $components = array('Security');在我的控制器中,我没有尝试这样做,太奇怪了?
  • 这很奇怪。没有那部分,您甚至无法使用该组件(至少,它不应该是可能的)。您可以扫描您的应用程序代码以查找“安全”事件吗?也许这有帮助?
  • 谢谢兄弟,我继承了系统,必须管理它,但是老开发者在另一个模板中调用它并将它应用到所有控制器。我修好了
  • 那么,我说的是解决方案还是..?因为在这种情况下,我会将其发布为“答案”,以便您可以将其标记为解决方案。这样其他有类似问题的人可以看看它。也可以为他们解决这个问题:)

标签: security cakephp


【解决方案1】:

您可以尝试使用SecurityComponent::validatePost 使用configuration option 用于:

这里我只是为特定操作定义的,您可以根据需要对其进行更改。

if(in_array($this->action,array(“some_action”))){
$this->Security->validatePost = false;

}

【讨论】:

    猜你喜欢
    • 2011-04-21
    • 1970-01-01
    • 1970-01-01
    • 2021-07-12
    • 2020-05-03
    • 2019-03-30
    • 1970-01-01
    • 2023-03-03
    • 2020-02-02
    相关资源
    最近更新 更多