2

我试图创建一个 URL 位置,另一个服务可以使用 cURL 库发送 json POST 数据。我收到 400 个 apache 错误并得到:

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

 Request blackholed due to "auth" violation.

在 CakePHP 应用程序中尝试禁用安全组件并在路由器中设置正确的路由,但这似乎没有帮助。

这是我的控制器操作、我的模型 beforeFind 和路线:

public function hello() {
    $data = $this->request->data;
    CakeLog::write('helloSignResponse', $data);
    if ($data) {
        $this->Security->validatePost = false;
        CakeLog::write('helloSignResponse', $data);
        if ($this->request->data['signature_request']['is_complete'] == true) {
            $signature = $this->request->data['signature_request']["signature_request_id"];
            $agent = $this->Agent->findBySignature('first', array('conditions' => $data['id'], 'feilds' => array('id')));
            $this->Agent->id = $agent['Agent']['id'];
            $this->User->id = $data['Agent']['user_id'];
            if (!( $this->Agent->saveFeild('status', 1) && $this->User->saveFeild('status', 1))) {
                CakeLog::write('helloSign', 'Did Not update the user status and agent status');
            }
        }
        return 'Hello API Event Received.';
    }
}

//Model

public function beforeFilter() {
    $this->Security->unlockedActions = array('hello');
    if ($this->action == 'hello') {
        $this->Security->csrfCheck = false;
        $this->Security->validatePost = false;
    }
}

//route
 Router::connect('/hello', array('plugin' => 'PhoneKarma', 'controller' => 'Agents', 'action' => 'hello'));

我还应该在 CakePHP 中做什么来防止这种情况或接受来自不同服务器的 POST 数据?

4

1 回答 1

1

我发现 beforeFilter 必须在控制器内,而不是这些功能工作的模型。这是工作前过滤器:

public function beforeFilter() {
    $this->Security->unlockedActions = array('hello');
    $this->Auth->allow('hello');
    parent::beforeFilter();
}
于 2013-06-12T19:26:10.607 回答