Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions en/controllers/components/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,16 @@ works::

public function beforeFilter(Event $event)
{
$this->Security->config('blackHoleCallback', 'blackhole');
$this->Security->setConfig('blackHoleCallback', 'blackhole');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should leave a comment that before 3.4.0 people should use config().

}

public function blackhole($type)
{
// Handle errors.
}

Note: use ``$this->Security->config()`` for CakePHP versions prior to 3.4

The ``$type`` parameter can have the following values:

* 'auth' Indicates a form validation error, or a controller/action mismatch
Expand Down Expand Up @@ -105,7 +107,8 @@ allowedActions
This can be used to control cross controller requests.

These configuration options allow you to restrict cross controller
communication. Set them with the ``config()`` method.
communication. Set them with the ``setConfig()`` method, or
``config()`` if you are using a CakePHP version below 3.4.

Form Tampering Prevention
=========================
Expand Down Expand Up @@ -139,7 +142,8 @@ validatePost
Set to ``false`` to completely skip the validation of POST
requests, essentially turning off form validation.

The above configuration options can be set with ``config()``.
The above configuration options can be set with ``setConfig()`` or
``config()`` for CakePHP versions below 3.4.

Usage
=====
Expand Down Expand Up @@ -241,10 +245,12 @@ There may be cases where you want to disable all security checks for an action

public function beforeFilter(Event $event)
{
$this->Security->config('unlockedActions', ['edit']);
$this->Security->setConfig('unlockedActions', ['edit']);
}
}

Note: use ``$this->Security->config()`` for CakePHP versions prior to 3.4

This example would disable all security checks for the edit action.

.. meta::
Expand Down