@@ -67,7 +67,7 @@ configuration looks like this:
67
67
68
68
<firewall name =" dev"
69
69
pattern =" ^/(_(profiler|wdt)|css|images|js)/"
70
- security =false />
70
+ security =" false" />
71
71
72
72
<firewall name =" default" >
73
73
<anonymous />
@@ -81,7 +81,7 @@ configuration looks like this:
81
81
$container->loadFromExtension('security', array(
82
82
'providers' => array(
83
83
'in_memory' => array(
84
- 'memory' => array() ,
84
+ 'memory' => null ,
85
85
),
86
86
),
87
87
'firewalls' => array(
@@ -209,6 +209,8 @@ user to be logged in to access this URL:
209
209
# ...
210
210
firewalls :
211
211
# ...
212
+ default :
213
+ # ...
212
214
213
215
access_control :
214
216
# require ROLE_ADMIN for /admin*
@@ -231,10 +233,8 @@ user to be logged in to access this URL:
231
233
<!-- ... -->
232
234
</firewall >
233
235
234
- <access-control >
235
- <!-- require ROLE_ADMIN for /admin* -->
236
- <rule path =" ^/admin" role =" ROLE_ADMIN" />
237
- </access-control >
236
+ <!-- require ROLE_ADMIN for /admin* -->
237
+ <rule path =" ^/admin" role =" ROLE_ADMIN" />
238
238
</config >
239
239
</srv : container >
240
240
@@ -541,20 +541,23 @@ like this:
541
541
http://symfony.com/schema/dic/services/services-1.0.xsd" >
542
542
543
543
<config >
544
+ <!-- ... -->
545
+
544
546
<provider name =" in_memory" >
545
547
<memory >
546
548
<user name =" ryan" password =" $2a$12$LCY0MefVIEc3TYPHV9SNnuzOfyr2p/AXIGoQJEDs4am4JwhNz/jli" roles =" ROLE_USER" />
547
549
<user name =" admin" password =" $2a$12$cyTWeE9kpq1PjqKFiWUZFuCRPwVyAZwm4XzMZ1qPUFl7/flCM3V0G" roles =" ROLE_ADMIN" />
548
550
</memory >
549
551
</provider >
550
- <!-- ... -->
551
552
</config >
552
553
</srv : container >
553
554
554
555
.. code-block :: php
555
556
556
557
// app/config/security.php
557
558
$container->loadFromExtension('security', array(
559
+ // ...
560
+
558
561
'providers' => array(
559
562
'in_memory' => array(
560
563
'memory' => array(
@@ -691,8 +694,11 @@ URL pattern. You saw this earlier, where anything matching the regular expressio
691
694
# app/config/security.yml
692
695
security :
693
696
# ...
697
+
694
698
firewalls :
695
699
# ...
700
+ default :
701
+ # ...
696
702
697
703
access_control :
698
704
# require ROLE_ADMIN for /admin*
@@ -715,10 +721,8 @@ URL pattern. You saw this earlier, where anything matching the regular expressio
715
721
<!-- ... -->
716
722
</firewall >
717
723
718
- <access-control >
719
- <!-- require ROLE_ADMIN for /admin* -->
720
- <rule path =" ^/admin" role =" ROLE_ADMIN" />
721
- </access-control >
724
+ <!-- require ROLE_ADMIN for /admin* -->
725
+ <rule path =" ^/admin" role =" ROLE_ADMIN" />
722
726
</config >
723
727
</srv : container >
724
728
@@ -727,6 +731,7 @@ URL pattern. You saw this earlier, where anything matching the regular expressio
727
731
// app/config/security.php
728
732
$container->loadFromExtension('security', array(
729
733
// ...
734
+
730
735
'firewalls' => array(
731
736
// ...
732
737
'default' => array(
@@ -755,6 +760,7 @@ matches the URL.
755
760
# app/config/security.yml
756
761
security :
757
762
# ...
763
+
758
764
access_control :
759
765
- { path: ^/admin/users, roles: ROLE_SUPER_ADMIN }
760
766
- { path: ^/admin, roles: ROLE_ADMIN }
@@ -771,10 +777,9 @@ matches the URL.
771
777
772
778
<config >
773
779
<!-- ... -->
774
- <access-control >
775
- <rule path =" ^/admin/users" role =" ROLE_SUPER_ADMIN" />
776
- <rule path =" ^/admin" role =" ROLE_ADMIN" />
777
- </access-control >
780
+
781
+ <rule path =" ^/admin/users" role =" ROLE_SUPER_ADMIN" />
782
+ <rule path =" ^/admin" role =" ROLE_ADMIN" />
778
783
</config >
779
784
</srv : container >
780
785
@@ -783,6 +788,7 @@ matches the URL.
783
788
// app/config/security.php
784
789
$container->loadFromExtension('security', array(
785
790
// ...
791
+
786
792
'access_control' => array(
787
793
array('path' => '^/admin/users', 'role' => 'ROLE_SUPER_ADMIN'),
788
794
array('path' => '^/admin', 'role' => 'ROLE_ADMIN'),
@@ -1037,13 +1043,14 @@ the firewall can handle this automatically for you when you activate the
1037
1043
1038
1044
# app/config/security.yml
1039
1045
security :
1046
+ # ...
1047
+
1040
1048
firewalls :
1041
1049
secured_area :
1042
1050
# ...
1043
1051
logout :
1044
1052
path : /logout
1045
1053
target : /
1046
- # ...
1047
1054
1048
1055
.. code-block :: xml
1049
1056
@@ -1056,25 +1063,27 @@ the firewall can handle this automatically for you when you activate the
1056
1063
http://symfony.com/schema/dic/services/services-1.0.xsd" >
1057
1064
1058
1065
<config >
1059
- <firewall name =" secured_area" pattern =" ^/" >
1066
+ <!-- ... -->
1067
+
1068
+ <firewall name =" secured_area" >
1060
1069
<!-- ... -->
1061
1070
<logout path =" /logout" target =" /" />
1062
1071
</firewall >
1063
- <!-- ... -->
1064
1072
</config >
1065
1073
</srv : container >
1066
1074
1067
1075
.. code-block :: php
1068
1076
1069
1077
// app/config/security.php
1070
1078
$container->loadFromExtension('security', array(
1079
+ // ...
1080
+
1071
1081
'firewalls' => array(
1072
1082
'secured_area' => array(
1073
1083
// ...
1074
- 'logout' => array('path' => 'logout', 'target' => '/'),
1084
+ 'logout' => array('path' => '/ logout', 'target' => '/'),
1075
1085
),
1076
1086
),
1077
- // ...
1078
1087
));
1079
1088
1080
1089
Next, you'll need to create a route for this URL (but not a controller):
@@ -1085,7 +1094,7 @@ Next, you'll need to create a route for this URL (but not a controller):
1085
1094
1086
1095
# app/config/routing.yml
1087
1096
logout :
1088
- path : /logout
1097
+ path : /logout
1089
1098
1090
1099
.. code-block :: xml
1091
1100
@@ -1106,7 +1115,7 @@ Next, you'll need to create a route for this URL (but not a controller):
1106
1115
use Symfony\Component\Routing\Route;
1107
1116
1108
1117
$collection = new RouteCollection();
1109
- $collection->add('logout', new Route('/logout', array() ));
1118
+ $collection->add('logout', new Route('/logout'));
1110
1119
1111
1120
return $collection;
1112
1121
@@ -1171,6 +1180,8 @@ rules by creating a role hierarchy:
1171
1180
1172
1181
# app/config/security.yml
1173
1182
security :
1183
+ # ...
1184
+
1174
1185
role_hierarchy :
1175
1186
ROLE_ADMIN : ROLE_USER
1176
1187
ROLE_SUPER_ADMIN : [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
@@ -1186,6 +1197,8 @@ rules by creating a role hierarchy:
1186
1197
http://symfony.com/schema/dic/services/services-1.0.xsd" >
1187
1198
1188
1199
<config >
1200 + <!-- ... -->
1201
+
1189
1202
<role id =" ROLE_ADMIN" >ROLE_USER</role >
1190
1203
<role id =" ROLE_SUPER_ADMIN" >ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH</role >
1191
1204
</config >
@@ -1195,6 +1208,8 @@ rules by creating a role hierarchy:
1195
1208
1196
1209
// app/config/security.php
1197
1210
$container->loadFromExtension('security', array(
1211
+ // ...
1212
+
1198
1213
'role_hierarchy' => array(
1199
1214
'ROLE_ADMIN' => 'ROLE_USER',
1200
1215
'ROLE_SUPER_ADMIN' => array(
@@ -1224,6 +1239,8 @@ cookie will be ever created by Symfony):
1224
1239
1225
1240
# app/config/security.yml
1226
1241
security :
1242
+ # ...
1243
+
1227
1244
firewalls :
1228
1245
main :
1229
1246
http_basic : ~
@@ -1240,7 +1257,9 @@ cookie will be ever created by Symfony):
1240
1257
http://symfony.com/schema/dic/services/services-1.0.xsd" >
1241
1258
1242
1259
<config >
1243
- <firewall stateless =" true" >
1260
+ <!-- ... -->
1261
+
1262
+ <firewall name =" main" stateless =" true" >
1244
1263
<http-basic />
1245
1264
</firewall >
1246
1265
</config >
@@ -1250,8 +1269,10 @@ cookie will be ever created by Symfony):
1250
1269
1251
1270
// app/config/security.php
1252
1271
$container->loadFromExtension('security', array(
1272
+ // ...
1273
+
1253
1274
'firewalls' => array(
1254
- 'main' => array('http_basic' => array() , 'stateless' => true),
1275
+ 'main' => array('http_basic' => null , 'stateless' => true),
1255
1276
),
1256
1277
));
1257
1278
0 commit comments