Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added `disabledActions` feature to SecurityComponent

  • Loading branch information...
commit df8ec176267ce06ff6ac04e646f3f6be052c8df9 1 parent 568c60d
@tigrang tigrang authored
View
15 lib/Cake/Controller/Component/SecurityComponent.php
@@ -179,6 +179,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
*
* @var array
@@ -218,13 +225,11 @@ public function startup(Controller $controller) {
$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');
}
}
View
14 lib/Cake/Test/Case/Controller/Component/SecurityComponentTest.php
@@ -1372,4 +1372,18 @@ public function testCsrfLimit() {
$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);
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.