@@ -5,15 +5,15 @@ How to Restrict Firewalls to a Specific Request
55===============================================
66
77When using the Security component, you can create firewalls that match certain request options.
8- In most cases matching against the URL is sufficient but in special cases you can further
9- restrict the initialization of a firewall against other optionsfrom the request.
8+ In most cases, matching against the URL is sufficient, but in special cases you can further
9+ restrict the initialization of a firewall against other optionsof the request.
1010
1111..note ::
1212
1313 You can use any of this restrictions individually or mix them together to get
1414 your desired firewall configuration.
1515
16- Restricting bypattern
16+ Restricting byPattern
1717----------------------
1818
1919This is the default restriction and restricts a firewall to only be initialized if the request URL
@@ -26,11 +26,10 @@ matches the configured ``pattern``.
2626# app/config/security.yml
2727
2828# ...
29-
3029security :
3130firewalls :
3231secured_area :
33- pattern :^/admin
32+ pattern :^/admin
3433# ...
3534
3635 ..code-block ::xml
@@ -56,11 +55,10 @@ matches the configured ``pattern``.
5655 // app/config/security.php
5756
5857 // ...
59-
6058 $container->loadFromExtension('security', array(
6159 'firewalls' => array(
6260 'secured_area' => array(
63- 'pattern' => '^/admin',
61+ 'pattern' => '^/admin',
6462 // ...
6563 ),
6664 ),
@@ -71,16 +69,16 @@ activated if the URL starts (due to the ``^`` regex character) with ``/admin`. I
7169the URL does not match this pattern, the firewall will not be activated and subsequent
7270firewalls will have the opportunity to be matched for this request.
7371
74- Restricting byhost
72+ Restricting byHost
7573-------------------
7674
7775.. versionadded:: 2.4
7876 Support for restricting security firewalls to a specific host was introduced in
7977 Symfony 2.4.
8078
81- If matching against the pattern only is not enough, the request can also be matched against
82- ``host ``. When the configuration option ``host `` is set the firewall will be restricted to
83- only initialize if the host from the request matches against the configuration option .
79+ If matching against the`` pattern `` only is not enough, the request can also be matched against
80+ ``host ``. When the configuration option ``host `` is set, the firewall will be restricted to
81+ only initialize if the host from the request matches against the configuration.
8482
8583..configuration-block ::
8684
@@ -89,11 +87,10 @@ only initialize if the host from the request matches against the configuration o
8987# app/config/security.yml
9088
9189# ...
92-
9390security :
9491firewalls :
9592secured_area :
96- host :^admin\.example\.com$
93+ host :^admin\.example\.com$
9794# ...
9895
9996 ..code-block ::xml
@@ -119,11 +116,10 @@ only initialize if the host from the request matches against the configuration o
119116 // app/config/security.php
120117
121118 // ...
122-
123119 $container->loadFromExtension('security', array(
124120 'firewalls' => array(
125121 'secured_area' => array(
126- 'host' => '^admin\.example\.com$',
122+ 'host' => '^admin\.example\.com$',
127123 // ...
128124 ),
129125 ),
@@ -136,7 +132,7 @@ If the hostname does not match this pattern, the firewall will not be activated
136132and subsequent firewalls will have the opportunity to be matched for this
137133request.
138134
139- Restricting byhttp methods
135+ Restricting byHttp Methods
140136---------------------------
141137
142138..versionadded ::2.5
@@ -153,11 +149,10 @@ the provided http methods.
153149# app/config/security.yml
154150
155151# ...
156-
157152security :
158153firewalls :
159154secured_area :
160- methods :[GET, POST]
155+ methods :[GET, POST]
161156# ...
162157
163158 ..code-block ::xml
@@ -183,11 +178,10 @@ the provided http methods.
183178 // app/config/security.php
184179
185180 // ...
186-
187181 $container->loadFromExtension('security', array(
188182 'firewalls' => array(
189183 'secured_area' => array(
190- 'methods' => array('GET', 'POST'),
184+ 'methods' => array('GET', 'POST'),
191185 // ...
192186 ),
193187 ),