Skip to content

Commit 7401ca9

Browse files
authored
Merge pull request #5661 from kenjis/fix-docs-method-filter
docs: add warning about $method filters
2 parents 90257e5 + 7f182e1 commit 7401ca9

File tree

6 files changed

+26
-2
lines changed

6 files changed

+26
-2
lines changed

app/Config/Filters.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ class Filters extends BaseConfig
4949
* particular HTTP method (GET, POST, etc.).
5050
*
5151
* Example:
52-
* 'post' => ['csrf', 'throttle']
52+
* 'post' => ['foo', 'bar']
53+
*
54+
* If you use this, you should disable auto-routing because auto-routing
55+
* permits any HTTP method to access a controller. Accessing the controller
56+
* with a method you don’t expect could bypass the filter.
5357
*
5458
* @var array
5559
*/

user_guide_src/source/incoming/filters.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ specify the method name in lowercase. It's value would be an array of filters to
176176
In addition to the standard HTTP methods, this also supports one special case: 'cli'. The 'cli' method would apply to
177177
all requests that were run from the command line.
178178

179+
.. Warning:: If you use ``$methods`` filters, you should :ref:`disable auto-routing <use-defined-routes-only>`
180+
because auto-routing permits any HTTP method to access a controller.
181+
Accessing the controller with a method you don't expect could bypass the filter.
182+
179183
$filters
180184
========
181185

user_guide_src/source/installation/upgrade_415.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ If you want the same behavior as the previous version, set the CSRF filter like
5353

5454
Protecting **GET** method needs only when you use ``form_open()`` auto-generation of CSRF field.
5555

56+
.. Warning:: In general, if you use ``$methods`` filters, you should :ref:`disable auto-routing <use-defined-routes-only>`
57+
because auto-routing permits any HTTP method to access a controller.
58+
Accessing the controller with a method you don't expect could bypass the filter.
59+
5660
CURLRequest header change
5761
-------------------------
5862

user_guide_src/source/libraries/security.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ It is also possible to enable the CSRF filter only for specific methods::
129129
'post' => ['csrf'],
130130
];
131131

132+
.. Warning:: If you use ``$methods`` filters, you should :ref:`disable auto-routing <use-defined-routes-only>`
133+
because auto-routing permits any HTTP method to access a controller.
134+
Accessing the controller with a method you don't expect could bypass the filter.
135+
132136
HTML Forms
133137
==========
134138

user_guide_src/source/libraries/throttler.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,13 @@ filter::
117117
Next, we assign it to all POST requests made on the site::
118118

119119
public $methods = [
120-
'post' => ['throttle', 'csrf'],
120+
'post' => ['throttle'],
121121
];
122122

123+
.. Warning:: If you use ``$methods`` filters, you should :ref:`disable auto-routing <use-defined-routes-only>`
124+
because auto-routing permits any HTTP method to access a controller.
125+
Accessing the controller with a method you don't expect could bypass the filter.
126+
123127
And that's all there is to it. Now all POST requests made on the site will have to be rate limited.
124128

125129
***************

user_guide_src/source/tutorial/create_news_items.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Open the **app/Config/Filters.php** file and update the ``$methods`` property li
2020
It configures the CSRF filter to be enabled for all **POST** requests.
2121
You can read more about the CSRF protection in :doc:`Security </libraries/security>` library.
2222

23+
.. Warning:: In general, if you use ``$methods`` filters, you should :ref:`disable auto-routing <use-defined-routes-only>`
24+
because auto-routing permits any HTTP method to access a controller.
25+
Accessing the controller with a method you don't expect could bypass the filter.
26+
2327
Create a form
2428
-------------
2529

0 commit comments

Comments
 (0)