@@ -5,15 +5,15 @@ How to Restrict Firewalls to a Specific Request
5
5
===============================================
6
6
7
7
When 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 options from 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 options of the request.
10
10
11
11
.. note ::
12
12
13
13
You can use any of this restrictions individually or mix them together to get
14
14
your desired firewall configuration.
15
15
16
- Restricting by pattern
16
+ Restricting by Pattern
17
17
----------------------
18
18
19
19
This is the default restriction and restricts a firewall to only be initialized if the request URL
@@ -26,11 +26,10 @@ matches the configured ``pattern``.
26
26
# app/config/security.yml
27
27
28
28
# ...
29
-
30
29
security :
31
30
firewalls :
32
31
secured_area :
33
- pattern : ^/admin
32
+ pattern : ^/admin
34
33
# ...
35
34
36
35
.. code-block :: xml
@@ -56,11 +55,10 @@ matches the configured ``pattern``.
56
55
// app/config/security.php
57
56
58
57
// ...
59
-
60
58
$container->loadFromExtension('security', array(
61
59
'firewalls' => array(
62
60
'secured_area' => array(
63
- 'pattern' => '^/admin',
61
+ 'pattern' => '^/admin',
64
62
// ...
65
63
),
66
64
),
@@ -71,16 +69,16 @@ activated if the URL starts (due to the ``^`` regex character) with ``/admin`. I
71
69
the URL does not match this pattern, the firewall will not be activated and subsequent
72
70
firewalls will have the opportunity to be matched for this request.
73
71
74
- Restricting by host
72
+ Restricting by Host
75
73
-------------------
76
74
77
75
.. versionadded:: 2.4
78
76
Support for restricting security firewalls to a specific host was introduced in
79
77
Symfony 2.4.
80
78
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.
84
82
85
83
.. configuration-block ::
86
84
@@ -89,11 +87,10 @@ only initialize if the host from the request matches against the configuration o
89
87
# app/config/security.yml
90
88
91
89
# ...
92
-
93
90
security :
94
91
firewalls :
95
92
secured_area :
96
- host : ^admin\.example\.com$
93
+ host : ^admin\.example\.com$
97
94
# ...
98
95
99
96
.. code-block :: xml
@@ -119,11 +116,10 @@ only initialize if the host from the request matches against the configuration o
119
116
// app/config/security.php
120
117
121
118
// ...
122
-
123
119
$container->loadFromExtension('security', array(
124
120
'firewalls' => array(
125
121
'secured_area' => array(
126
- 'host' => '^admin\.example\.com$',
122
+ 'host' => '^admin\.example\.com$',
127
123
// ...
128
124
),
129
125
),
@@ -136,7 +132,7 @@ If the hostname does not match this pattern, the firewall will not be activated
136
132
and subsequent firewalls will have the opportunity to be matched for this
137
133
request.
138
134
139
- Restricting by http methods
135
+ Restricting by Http Methods
140
136
---------------------------
141
137
142
138
.. versionadded :: 2.5
@@ -153,11 +149,10 @@ the provided http methods.
153
149
# app/config/security.yml
154
150
155
151
# ...
156
-
157
152
security :
158
153
firewalls :
159
154
secured_area :
160
- methods : [GET, POST]
155
+ methods : [GET, POST]
161
156
# ...
162
157
163
158
.. code-block :: xml
@@ -183,11 +178,10 @@ the provided http methods.
183
178
// app/config/security.php
184
179
185
180
// ...
186
-
187
181
$container->loadFromExtension('security', array(
188
182
'firewalls' => array(
189
183
'secured_area' => array(
190
- 'methods' => array('GET', 'POST'),
184
+ 'methods' => array('GET', 'POST'),
191
185
// ...
192
186
),
193
187
),
0 commit comments