Skip to content

Commit

Permalink
[SecurityBundle] Allow an array of pattern in firewall configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-daubois committed Jul 27, 2023
1 parent a74090b commit 66a7330
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,55 @@ The ``dev`` firewall is really a fake firewall: it makes sure that you
don't accidentally block Symfony's dev tools - which live under URLs like
``/_profiler`` and ``/_wdt``.

.. tip::

Instead of creating one long regex to match all routes you want, you're
also able to use an array of simpler regexes to match routes:

.. configuration-block::

.. code-block:: yaml
# config/packages/security.yaml
security:
# ...
firewalls:
dev:
pattern:
- ^/_profiler/
- ^/_wdt/
- ^/css/
- ^/images/
- ^/js/
# ...
.. code-block:: php
// config/packages/security.php
use Symfony\Config\SecurityConfig;
return static function (SecurityConfig $security): void {
// ...
$security->firewall('dev')
->pattern([
'^/_profiler/',
'^/_wdt/',
'^/css/',
'^/images/',
'^/js/',
])
->security(false)
;
// ...
};
This feature is not supported by the XML configuration format.

.. versionadded:: 6.4

The possibility to use an array of regex was introduced in Symfony 6.4.

All *real* URLs are handled by the ``main`` firewall (no ``pattern`` key means
it matches *all* URLs). A firewall can have many modes of authentication,
in other words, it enables many ways to ask the question "Who are you?".
Expand Down

0 comments on commit 66a7330

Please sign in to comment.