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
20 changes: 10 additions & 10 deletions security/access_control.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ Take the following ``access_control`` entries as an example:
security:
# ...
access_control:
- { path: '^/admin', roles: ROLE_USER_IP, ip: 127.0.0.1 }
- { path: '^/admin', roles: ROLE_USER_PORT, ip: 127.0.0.1, port: 8080 }
- { path: '^/admin', roles: ROLE_USER_IP, ip: 127.0.0.1 }
- { path: '^/admin', roles: ROLE_USER_HOST, host: symfony\.com$ }
- { path: '^/admin', roles: ROLE_USER_METHOD, methods: [POST, PUT] }
# when defining multiple roles, users must have at least one of them (it's like an OR condition)
Expand All @@ -59,8 +59,8 @@ Take the following ``access_control`` entries as an example:

<config>
<!-- ... -->
<rule path="^/admin" role="ROLE_USER_IP" ip="127.0.0.1"/>
<rule path="^/admin" role="ROLE_USER_PORT" ip="127.0.0.1" port="8080"/>
<rule path="^/admin" role="ROLE_USER_IP" ip="127.0.0.1"/>
<rule path="^/admin" role="ROLE_USER_HOST" host="symfony\.com$"/>
<rule path="^/admin" role="ROLE_USER_METHOD" methods="POST, PUT"/>
<!-- when defining multiple roles, users must have at least one of them (it's like an OR condition) -->
Expand All @@ -74,17 +74,17 @@ Take the following ``access_control`` entries as an example:
$container->loadFromExtension('security', [
// ...
'access_control' => [
[
'path' => '^/admin',
'roles' => 'ROLE_USER_IP',
'ips' => '127.0.0.1',
],
[
'path' => '^/admin',
'roles' => 'ROLE_USER_PORT',
'ip' => '127.0.0.1',
'port' => '8080',
],
[
'path' => '^/admin',
'roles' => 'ROLE_USER_IP',
'ips' => '127.0.0.1',
],
[
'path' => '^/admin',
'roles' => 'ROLE_USER_HOST',
Expand Down Expand Up @@ -112,13 +112,13 @@ if ``ip``, ``port``, ``host`` or ``method`` are not specified for an entry, that
+-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
| URI | IP | PORT | HOST | METHOD | ``access_control`` | Why? |
+=================+=============+=============+=============+============+================================+=============================================================+
| ``/admin/user`` | 127.0.0.1 | 80 | example.com | GET | rule #1 (``ROLE_USER_IP``) | The URI matches ``path`` and the IP matches ``ip``. |
| ``/admin/user`` | 127.0.0.1 | 80 | example.com | GET | rule #2 (``ROLE_USER_IP``) | The URI matches ``path`` and the IP matches ``ip``. |
+-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
| ``/admin/user`` | 127.0.0.1 | 80 | symfony.com | GET | rule #1 (``ROLE_USER_IP``) | The ``path`` and ``ip`` still match. This would also match |
| ``/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 |
| | | | | | | the ``ROLE_USER_HOST`` entry, but *only* the **first** |
| | | | | | | ``access_control`` match is used. |
+-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
| ``/admin/user`` | 127.0.0.1 | 8080 | symfony.com | GET | rule #2 (``ROLE_USER_PORT``) | The ``path``, ``ip`` and ``port`` match. |
| ``/admin/user`` | 127.0.0.1 | 8080 | symfony.com | GET | rule #1 (``ROLE_USER_PORT``) | The ``path``, ``ip`` and ``port`` match. |
+-----------------+-------------+-------------+-------------+------------+--------------------------------+-------------------------------------------------------------+
| ``/admin/user`` | 168.0.0.1 | 80 | symfony.com | GET | rule #3 (``ROLE_USER_HOST``) | The ``ip`` doesn't match the first rule, so the second |
| | | | | | | rule (which matches) is used. |
Expand Down