Skip to content

Commit 393823c

Browse files
committed
feature #18617 [Security] Allow an array of pattern in firewall configuration (alexandre-daubois)
This PR was merged into the 6.4 branch. Discussion ---------- [Security] Allow an array of pattern in firewall configuration Related to symfony/symfony#51128 Commits ------- 66a7330 [SecurityBundle] Allow an array of pattern in firewall configuration
2 parents 7cc92d5 + 66a7330 commit 393823c

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

security.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,55 @@ The ``dev`` firewall is really a fake firewall: it makes sure that you
561561
don't accidentally block Symfony's dev tools - which live under URLs like
562562
``/_profiler`` and ``/_wdt``.
563563

564+
.. tip::
565+
566+
Instead of creating one long regex to match all routes you want, you're
567+
also able to use an array of simpler regexes to match routes:
568+
569+
.. configuration-block::
570+
571+
.. code-block:: yaml
572+
573+
# config/packages/security.yaml
574+
security:
575+
# ...
576+
firewalls:
577+
dev:
578+
pattern:
579+
- ^/_profiler/
580+
- ^/_wdt/
581+
- ^/css/
582+
- ^/images/
583+
- ^/js/
584+
# ...
585+
586+
.. code-block:: php
587+
588+
// config/packages/security.php
589+
use Symfony\Config\SecurityConfig;
590+
591+
return static function (SecurityConfig $security): void {
592+
// ...
593+
$security->firewall('dev')
594+
->pattern([
595+
'^/_profiler/',
596+
'^/_wdt/',
597+
'^/css/',
598+
'^/images/',
599+
'^/js/',
600+
])
601+
->security(false)
602+
;
603+
604+
// ...
605+
};
606+
607+
This feature is not supported by the XML configuration format.
608+
609+
.. versionadded:: 6.4
610+
611+
The possibility to use an array of regex was introduced in Symfony 6.4.
612+
564613
All *real* URLs are handled by the ``main`` firewall (no ``pattern`` key means
565614
it matches *all* URLs). A firewall can have many modes of authentication,
566615
in other words, it enables many ways to ask the question "Who are you?".

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy