diff --git a/security/access_control.rst b/security/access_control.rst index d7a96345b8e..385a499d2fb 100644 --- a/security/access_control.rst +++ b/security/access_control.rst @@ -133,6 +133,73 @@ if ``ip``, ``port``, ``host`` or ``method`` are not specified for an entry, that :ref:`Deny access in PHP code ` if you want to disallow access based on ``$_GET`` parameter values. +.. versionadded:: 5.2 + + Environment variables can be used to pass comma separated ip addresses + (as a single value or as one of array values): + + .. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + parameters: + env(TRUSTED_IPS): '10.0.0.1, 10.0.0.2' + security: + # ... + access_control: + - { path: '^/admin', ips: '%env(TRUSTED_IPS)%' } + - { path: '^/admin', ips: [127.0.0.1, ::1, '%env(TRUSTED_IPS)%'] } + + .. code-block:: xml + + + + + + + 10.0.0.1, 10.0.0.2 + + + + + + + 127.0.0.1 + ::1 + %env(TRUSTED_IPS)% + + + + + .. code-block:: php + + // config/packages/security.php + $container->setParameter('env(TRUSTED_IPS)', '10.0.0.1, 10.0.0.2'); + $container->loadFromExtension('security', [ + // ... + 'access_control' => [ + [ + 'path' => '^/admin', + 'ips' => '%env(TRUSTED_IPS)%', + ], + [ + 'path' => '^/admin', + 'ips' => [ + '127.0.0.1', + '::1', + '%env(TRUSTED_IPS)%', + ], + ], + ], + ]); + .. _security-access-control-enforcement-options: 2. Access Enforcement