File tree 3 files changed +64
-0
lines changed
3 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 132
132
* :doc:` /cookbook/security/acl`
133
133
* :doc:` /cookbook/security/acl_advanced`
134
134
* :doc:` /cookbook/security/force_https`
135
+ * :doc:` /cookbook/security/host_restriction`
135
136
* :doc:` /cookbook/security/form_login`
136
137
* :doc:` /cookbook/security/securing_services`
137
138
* :doc:` /cookbook/security/custom_provider`
Original file line number Diff line number Diff line change
1
+ .. index ::
2
+ single: Security; Restrict Security Firewalls to a Host
3
+
4
+ How to restrict Firewalls to a Specific Host
5
+ ============================================
6
+
7
+ .. versionadded :: 2.4
8
+ Support for restricting security firewalls to a specific host was added in
9
+ Symfony 2.4.
10
+
11
+ When using the Security component, you can create firewalls that match certain
12
+ url patterns and thereby restrict access to all urls matching these patterns.
13
+ Additionally, you can restrict a firewall to a host using the ``host `` key:
14
+
15
+ .. configuration-block ::
16
+
17
+ .. code-block :: yaml
18
+
19
+ # app/config/security.yml
20
+
21
+ # ...
22
+
23
+ security :
24
+ firewalls :
25
+ secured_area :
26
+ pattern : ^/
27
+ host : admin\.example\.com
28
+ http_basic : true
29
+
30
+ .. code-block :: xml
31
+
32
+ <!-- app/config/security.xml -->
33
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
34
+ <srv : container xmlns =" http://symfony.com/schema/dic/security"
35
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
36
+ xmlns : srv =" http://symfony.com/schema/dic/services"
37
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
38
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
39
+
40
+ <config >
41
+ <!-- ... -->
42
+ <firewall name =" secured_area" pattern =" ^/" host =" admin.example.com" >
43
+ <http-basic />
44
+ </firewall >
45
+ </config >
46
+ </srv : container >
47
+
48
+ .. code-block :: php
49
+
50
+ // app/config/security.php
51
+
52
+ // ...
53
+
54
+ $container->loadFromExtension('security', array(
55
+ 'firewalls' => array(
56
+ 'secured_area' => array(
57
+ 'pattern' => '^/',
58
+ 'host' => 'admin.example.com',
59
+ 'http_basic' => true,
60
+ ),
61
+ ),
62
+ ));
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ Security
10
10
acl
11
11
acl_advanced
12
12
force_https
13
+ host_restriction
13
14
form_login
14
15
securing_services
15
16
custom_provider
You can’t perform that action at this time.
0 commit comments