@@ -177,33 +177,49 @@ For each incoming request, Symfony will decide which ``access_control``
177177to use based on the URI, the client's IP address, the incoming host name,
178178and the request method. Remember, the first rule that matches is used, and
179179if ``ip ``, ``port ``, ``host `` or ``method `` are not specified for an entry, that
180- ``access_control `` will match any ``ip ``, ``port ``, ``host `` or ``method ``:
181-
182- +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
183- | URI | IP | PORT | HOST | METHOD | ``access_control `` | Why? |
184- +=================+=============+=============+=============+============+================================+=============================================================+
185- | ``/admin/user `` | 127.0.0.1 | 80 | example.com | GET | rule #2 (``ROLE_USER_IP ``) | The URI matches ``path `` and the IP matches ``ip ``. |
186- +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
187- | ``/admin/user `` | 127.0.0.1 | 80 | symfony.com | GET | rule #2 (``ROLE_USER_IP ``) | The ``path `` and ``ip `` still match. This would also match |
188- | | | | | | | the ``ROLE_USER_HOST `` entry, but *only * the **first ** |
189- | | | | | | | ``access_control `` match is used. |
190- +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
191- | ``/admin/user `` | 127.0.0.1 | 8080 | symfony.com | GET | rule #1 (``ROLE_USER_PORT ``) | The ``path ``, ``ip `` and ``port `` match. |
192- +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
193- | ``/admin/user `` | 168.0.0.1 | 80 | symfony.com | GET | rule #3 (``ROLE_USER_HOST ``) | The ``ip `` doesn't match neither the first rule nor the |
194- | | | | | | | second rule. So the third rule (which matches) is used. |
195- +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
196- | ``/admin/user `` | 168.0.0.1 | 80 | symfony.com | POST | rule #3 (``ROLE_USER_HOST ``) | The third rule still matches. This would also match the |
197- | | | | | | | fourth rule (``ROLE_USER_METHOD ``), but only the **first ** |
198- | | | | | | | matched ``access_control `` is used. |
199- +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
200- | ``/admin/user `` | 168.0.0.1 | 80 | example.com | POST | rule #4 (``ROLE_USER_METHOD ``) | The ``ip `` and ``host `` don't match the first three |
201- | | | | | | | entries, but the fourth - ``ROLE_USER_METHOD `` - matches |
202- | | | | | | | and is used. |
203- +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
204- | ``/foo `` | 127.0.0.1 | 80 | symfony.com | POST | matches no entries | This doesn't match any ``access_control `` rules, since its |
205- | | | | | | | URI doesn't match any of the ``path `` values. |
206- +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
180+ ``access_control `` will match any ``ip ``, ``port ``, ``host `` or ``method ``.
181+ See the following examples:
182+
183+ Example #1:
184+ * **URI ** ``/admin/user ``
185+ * **IP **: ``127.0.0.1 ``, **Port **: ``80 ``, **Host **: ``example.com ``, **Method **: ``GET ``
186+ * **Rule applied **: rule #2 (``ROLE_USER_IP ``)
187+ * **Why? ** The URI matches ``path `` and the IP matches ``ip ``.
188+ Example #2:
189+ * **URI ** ``/admin/user ``
190+ * **IP **: ``127.0.0.1 ``, **Port **: ``80 ``, **Host **: ``symfony.com ``, **Method **: ``GET ``
191+ * **Rule applied **: rule #2 (``ROLE_USER_IP ``)
192+ * **Why? ** The ``path `` and ``ip `` still match. This would also match the
193+ ``ROLE_USER_HOST `` entry, but *only * the **first ** ``access_control `` match is used.
194+ Example #3:
195+ * **URI ** ``/admin/user ``
196+ * **IP **: ``127.0.0.1 ``, **Port **: ``8080 ``, **Host **: ``symfony.com ``, **Method **: ``GET ``
197+ * **Rule applied **: rule #1 (``ROLE_USER_PORT ``)
198+ * **Why? ** The ``path ``, ``ip `` and ``port `` match.
199+ Example #4:
200+ * **URI ** ``/admin/user ``
201+ * **IP **: ``168.0.0.1 ``, **Port **: ``80 ``, **Host **: ``symfony.com ``, **Method **: ``GET ``
202+ * **Rule applied **: rule #3 (``ROLE_USER_HOST ``)
203+ * **Why? ** The ``ip `` doesn't match neither the first rule nor the second rule.
204+ * So the third rule (which matches) is used.
205+ Example #5:
206+ * **URI ** ``/admin/user ``
207+ * **IP **: ``168.0.0.1 ``, **Port **: ``80 ``, **Host **: ``symfony.com ``, **Method **: ``POST ``
208+ * **Rule applied **: rule #3 (``ROLE_USER_HOST ``)
209+ * **Why? ** The third rule still matches. This would also match the fourth rule
210+ * (``ROLE_USER_METHOD ``), but only the **first ** matched ``access_control `` is used.
211+ Example #6:
212+ * **URI ** ``/admin/user ``
213+ * **IP **: ``168.0.0.1 ``, **Port **: ``80 ``, **Host **: ``example.com ``, **Method **: ``POST ``
214+ * **Rule applied **: rule #4 (``ROLE_USER_METHOD ``)
215+ * **Why? ** The ``ip `` and ``host `` don't match the first three entries, but
216+ * the fourth - ``ROLE_USER_METHOD `` - matches and is used.
217+ Example #7:
218+ * **URI ** ``/foo ``
219+ * **IP **: ``127.0.0.1 ``, **Port **: ``80 ``, **Host **: ``symfony.com ``, **Method **: ``POST ``
220+ * **Rule applied **: matches no entries
221+ * **Why? ** This doesn't match any ``access_control `` rules, since its URI
222+ * doesn't match any of the ``path `` values.
207223
208224.. caution ::
209225
0 commit comments