mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Added disabledActions
feature to SecurityComponent
This commit is contained in:
parent
568c60de9f
commit
df8ec17626
2 changed files with 24 additions and 5 deletions
|
@ -178,6 +178,13 @@ class SecurityComponent extends Component {
|
|||
*/
|
||||
public $csrfLimit = 100;
|
||||
|
||||
/**
|
||||
* List of actions to disable security checks
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $disabledActions = array();
|
||||
|
||||
/**
|
||||
* Other components used by the Security component
|
||||
*
|
||||
|
@ -218,13 +225,11 @@ class SecurityComponent extends Component {
|
|||
$controller->request->params['requested'] != 1
|
||||
);
|
||||
|
||||
if ($isPost && $isNotRequestAction && $this->validatePost) {
|
||||
if ($this->_validatePost($controller) === false) {
|
||||
if (!in_array($this->_action, (array)$this->disabledActions) && $isPost && $isNotRequestAction) {
|
||||
if ($this->validatePost && $this->_validatePost($controller) === false) {
|
||||
return $this->blackHole($controller, 'auth');
|
||||
}
|
||||
}
|
||||
if ($isPost && $isNotRequestAction && $this->csrfCheck) {
|
||||
if ($this->_validateCsrf($controller) === false) {
|
||||
if ($this->csrfCheck && $this->_validateCsrf($controller) === false) {
|
||||
return $this->blackHole($controller, 'csrf');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1372,4 +1372,18 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
$this->assertTrue(isset($result['4']));
|
||||
$this->assertTrue(isset($result['5']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test disabled actions
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDisabledActions() {
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$this->Controller->request->data = array('data');
|
||||
$this->Controller->Security->disabledActions = 'index';
|
||||
$this->Controller->Security->blackHoleCallback = null;
|
||||
$result = $this->Controller->Security->startup($this->Controller);
|
||||
$this->assertNull($result);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue