2013-06-12 27 views
2

我試圖創建一個URL位置,其他服務可以使用cURL庫發送json POST數據。即時得到400 apache的錯誤,並獲取:黑洞請求從單獨服務器捲曲發佈CakePHP

**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

我發現beforeFilter必須在控制器內,而不是這些函數的模型工作。這是在過濾之前的工作:

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

這是因爲'beforeFilter'是一個控制器方法,而不是一個模型方法。 – dogmatic69