来自单独服务器CakePHP的Curl Post的黑洞请求

时间:2013-06-12 09:04:03

标签: apache security cakephp post curl

我正在尝试创建一个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数据?

1 个答案:

答案 0 :(得分:1)

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

public function beforeFilter() {
    $this->Security->unlockedActions = array('hello');
    $this->Auth->allow('hello');
    parent::beforeFilter();
}