@@ -137,33 +137,49 @@ For each incoming request, Symfony will decide which ``access_control``
137137to use based on the URI, the client's IP address, the incoming host name,
138138and the request method. Remember, the first rule that matches is used, and
139139if ``ip ``, ``port ``, ``host `` or ``method `` are not specified for an entry, that
140- ``access_control `` will match any ``ip ``, ``port ``, ``host `` or ``method ``:
141-
142- +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
143- | URI | IP | PORT | HOST | METHOD | ``access_control `` | Why? |
144- +=================+=============+=============+=============+============+================================+=============================================================+
145- | ``/admin/user `` | 127.0.0.1 | 80 | example.com | GET | rule #2 (``ROLE_USER_IP ``) | The URI matches ``path `` and the IP matches ``ip ``. |
146- +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
147- | ``/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 |
148- | | | | | | | the ``ROLE_USER_HOST `` entry, but *only * the **first ** |
149- | | | | | | | ``access_control `` match is used. |
150- +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
151- | ``/admin/user `` | 127.0.0.1 | 8080 | symfony.com | GET | rule #1 (``ROLE_USER_PORT ``) | The ``path ``, ``ip `` and ``port `` match. |
152- +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
153- | ``/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 |
154- | | | | | | | second rule. So the third rule (which matches) is used. |
155- +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
156- | ``/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 |
157- | | | | | | | fourth rule (``ROLE_USER_METHOD ``), but only the **first ** |
158- | | | | | | | matched ``access_control `` is used. |
159- +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
160- | ``/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 |
161- | | | | | | | entries, but the fourth - ``ROLE_USER_METHOD `` - matches |
162- | | | | | | | and is used. |
163- +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
164- | ``/foo `` | 127.0.0.1 | 80 | symfony.com | POST | matches no entries | This doesn't match any ``access_control `` rules, since its |
165- | | | | | | | URI doesn't match any of the ``path `` values. |
166- +-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
140+ ``access_control `` will match any ``ip ``, ``port ``, ``host `` or ``method ``.
141+ See the following examples:
142+
143+ Example #1:
144+ * **URI ** ``/admin/user ``
145+ * **IP **: ``127.0.0.1 ``, **Port **: ``80 ``, **Host **: ``example.com ``, **Method **: ``GET ``
146+ * **Rule applied **: rule #2 (``ROLE_USER_IP ``)
147+ * **Why? ** The URI matches ``path `` and the IP matches ``ip ``.
148+ Example #2:
149+ * **URI ** ``/admin/user ``
150+ * **IP **: ``127.0.0.1 ``, **Port **: ``80 ``, **Host **: ``symfony.com ``, **Method **: ``GET ``
151+ * **Rule applied **: rule #2 (``ROLE_USER_IP ``)
152+ * **Why? ** The ``path `` and ``ip `` still match. This would also match the
153+ ``ROLE_USER_HOST `` entry, but *only * the **first ** ``access_control `` match is used.
154+ Example #3:
155+ * **URI ** ``/admin/user ``
156+ * **IP **: ``127.0.0.1 ``, **Port **: ``8080 ``, **Host **: ``symfony.com ``, **Method **: ``GET ``
157+ * **Rule applied **: rule #1 (``ROLE_USER_PORT ``)
158+ * **Why? ** The ``path ``, ``ip `` and ``port `` match.
159+ Example #4:
160+ * **URI ** ``/admin/user ``
161+ * **IP **: ``168.0.0.1 ``, **Port **: ``80 ``, **Host **: ``symfony.com ``, **Method **: ``GET ``
162+ * **Rule applied **: rule #3 (``ROLE_USER_HOST ``)
163+ * **Why? ** The ``ip `` doesn't match neither the first rule nor the second rule.
164+ * So the third rule (which matches) is used.
165+ Example #5:
166+ * **URI ** ``/admin/user ``
167+ * **IP **: ``168.0.0.1 ``, **Port **: ``80 ``, **Host **: ``symfony.com ``, **Method **: ``POST ``
168+ * **Rule applied **: rule #3 (``ROLE_USER_HOST ``)
169+ * **Why? ** The third rule still matches. This would also match the fourth rule
170+ * (``ROLE_USER_METHOD ``), but only the **first ** matched ``access_control `` is used.
171+ Example #6:
172+ * **URI ** ``/admin/user ``
173+ * **IP **: ``168.0.0.1 ``, **Port **: ``80 ``, **Host **: ``example.com ``, **Method **: ``POST ``
174+ * **Rule applied **: rule #4 (``ROLE_USER_METHOD ``)
175+ * **Why? ** The ``ip `` and ``host `` don't match the first three entries, but
176+ * the fourth - ``ROLE_USER_METHOD `` - matches and is used.
177+ Example #7:
178+ * **URI ** ``/foo ``
179+ * **IP **: ``127.0.0.1 ``, **Port **: ``80 ``, **Host **: ``symfony.com ``, **Method **: ``POST ``
180+ * **Rule applied **: matches no entries
181+ * **Why? ** This doesn't match any ``access_control `` rules, since its URI
182+ * doesn't match any of the ``path `` values.
167183
168184.. caution ::
169185
0 commit comments