@@ -770,7 +770,7 @@ access control should be used on this request. The following ``access_control``
770
770
options are used for matching:
771
771
772
772
* ``path ``
773
- * ``ip ``
773
+ * ``ip `` or `` ips ``
774
774
* ``host ``
775
775
* ``methods ``
776
776
@@ -877,6 +877,11 @@ prevent any direct access to these resources from a web browser (by guessing the
877
877
ESI URL pattern), the ESI route **must ** be secured to be only visible from
878
878
the trusted reverse proxy cache.
879
879
880
+ .. versionadded :: 2.3
881
+ Version 2.3 allows multiple IP addresses in a single rule with the ``ips: [a, b] ``
882
+ construct. Prior to 2.3, users should create one rule per IP address to match and
883
+ use the ``ip `` key instead of ``ips ``.
884
+
880
885
Here is an example of how you might secure all ESI routes that start with a
881
886
given prefix, ``/esi ``, from outside access:
882
887
@@ -888,36 +893,37 @@ given prefix, ``/esi``, from outside access:
888
893
security :
889
894
# ...
890
895
access_control :
891
- - { path: ^/esi, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }
896
+ - { path: ^/esi, roles: IS_AUTHENTICATED_ANONYMOUSLY, ips: [ 127.0.0.1, ::1] }
892
897
- { path: ^/esi, roles: ROLE_NO_ACCESS }
893
898
894
899
.. code-block :: xml
895
900
896
901
<access-control >
897
- <rule path =" ^/esi" role =" IS_AUTHENTICATED_ANONYMOUSLY" ip =" 127.0.0.1" />
902
+ <rule path =" ^/esi" role =" IS_AUTHENTICATED_ANONYMOUSLY" ips =" 127.0.0.1, :: 1" />
898
903
<rule path =" ^/esi" role =" ROLE_NO_ACCESS" />
899
904
</access-control >
900
905
901
906
.. code-block :: php
902
907
903
908
'access_control' => array(
904
- array('path' => '^/esi', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY', 'ip ' => '127.0.0.1'),
909
+ array('path' => '^/esi', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY', 'ips ' => '127.0.0.1, :: 1'),
905
910
array('path' => '^/esi', 'role' => 'ROLE_NO_ACCESS'),
906
911
),
907
912
908
913
Here is how it works when the path is ``/esi/something `` coming from the
909
914
``10.0.0.1 `` IP:
910
915
911
916
* The first access control rule is ignored as the ``path `` matches but the
912
- ``ip `` does not;
917
+ ``ip `` does not match either of the IPs listed ;
913
918
914
919
* The second access control rule is enabled (the only restriction being the
915
920
``path `` and it matches): as the user cannot have the ``ROLE_NO_ACCESS ``
916
921
role as it's not defined, access is denied (the ``ROLE_NO_ACCESS `` role can
917
922
be anything that does not match an existing role, it just serves as a trick
918
923
to always deny access).
919
924
920
- Now, if the same request comes from ``127.0.0.1 ``:
925
+ Now, if the same request comes from ``127.0.0.1 `` or ``::1 `` (the IPv6 loopback
926
+ address):
921
927
922
928
* Now, the first access control rule is enabled as both the ``path `` and the
923
929
``ip `` match: access is allowed as the user always has the
0 commit comments