|
|
@@ -104,39 +104,31 @@ class SecurityComponent extends Component
|
|
|
$controller = $event->subject();
|
|
|
$this->session = $this->request->session();
|
|
|
$this->_action = $this->request->params['action'];
|
|
|
+ $hasData = !empty($this->request->data);
|
|
|
try {
|
|
|
$this->_secureRequired($controller);
|
|
|
- } catch (SecurityException $se) {
|
|
|
- $this->blackHole($controller, $se->getType(), $se);
|
|
|
- }
|
|
|
- try {
|
|
|
$this->_authRequired($controller);
|
|
|
- } catch (AuthSecurityException $ase) {
|
|
|
- $this->blackHole($controller, $ase->getType(), $ase);
|
|
|
- }
|
|
|
|
|
|
+ $isNotRequestAction = (
|
|
|
+ !isset($controller->request->params['requested']) ||
|
|
|
+ $controller->request->params['requested'] != 1
|
|
|
+ );
|
|
|
|
|
|
- $hasData = !empty($this->request->data);
|
|
|
- $isNotRequestAction = (
|
|
|
- !isset($controller->request->params['requested']) ||
|
|
|
- $controller->request->params['requested'] != 1
|
|
|
- );
|
|
|
-
|
|
|
- if ($this->_action === $this->_config['blackHoleCallback']) {
|
|
|
- return $this->blackHole($controller, 'auth');
|
|
|
- }
|
|
|
+ if ($this->_action === $this->_config['blackHoleCallback']) {
|
|
|
+ throw new AuthSecurityException(sprintf('Action %s is defined as the blackhole callback.', $this->_action));
|
|
|
+ }
|
|
|
|
|
|
- if (!in_array($this->_action, (array)$this->_config['unlockedActions']) &&
|
|
|
- $hasData && $isNotRequestAction
|
|
|
- ) {
|
|
|
- if ($this->_config['validatePost']) {
|
|
|
- try {
|
|
|
+ if (!in_array($this->_action, (array)$this->_config['unlockedActions']) &&
|
|
|
+ $hasData && $isNotRequestAction
|
|
|
+ ) {
|
|
|
+ if ($this->_config['validatePost']) {
|
|
|
$this->_validatePost($controller);
|
|
|
- } catch (SecurityException $se) {
|
|
|
- return $this->blackHole($controller, $se->getType(), $se);
|
|
|
}
|
|
|
}
|
|
|
+ } catch (SecurityException $se) {
|
|
|
+ $this->blackHole($controller, $se->getType(), $se);
|
|
|
}
|
|
|
+
|
|
|
$this->generateToken($controller->request);
|
|
|
if ($hasData && is_array($controller->request->data)) {
|
|
|
unset($controller->request->data['_Token']);
|
|
|
@@ -188,7 +180,8 @@ class SecurityComponent extends Component
|
|
|
*
|
|
|
* @param \Cake\Controller\Controller $controller Instantiating controller
|
|
|
* @param string $error Error method
|
|
|
- * @param \Cake\Controller\Exception\SecurityException $exception Additional debug info describing the cause
|
|
|
+ * @param \Cake\Controller\Exception\SecurityException $exception Additional debug info describing the cause,
|
|
|
+ * debug mode only
|
|
|
* @return mixed If specified, controller blackHoleCallback's response, or no return otherwise
|
|
|
* @see SecurityComponent::$blackHoleCallback
|
|
|
* @link http://book.cakephp.org/3.0/en/controllers/components/security.html#handling-blackhole-callbacks
|
|
|
@@ -301,11 +294,7 @@ class SecurityComponent extends Component
|
|
|
* Validate submitted form
|
|
|
*
|
|
|
* @param \Cake\Controller\Controller $controller Instantiating controller
|
|
|
-<<<<<<< HEAD
|
|
|
* @throws \Cake\Controller\Exception\SecurityException
|
|
|
-=======
|
|
|
- * @throws SecurityException
|
|
|
->>>>>>> e73f064c716f82b627e39b5ad3730282202f6670
|
|
|
* @return bool true if submitted form is valid
|
|
|
*/
|
|
|
protected function _validatePost(Controller $controller)
|