17
17
use Symfony \Bundle \FrameworkBundle \Controller \AbstractController ;
18
18
use Symfony \Bundle \FrameworkBundle \Controller \Controller ;
19
19
use Symfony \Bundle \FrameworkBundle \Routing \AnnotatedRouteControllerLoader ;
20
+ use Symfony \Bundle \FullStack ;
20
21
use Symfony \Component \Cache \Adapter \AbstractAdapter ;
21
22
use Symfony \Component \Cache \Adapter \AdapterInterface ;
22
23
use Symfony \Component \Cache \Adapter \ArrayAdapter ;
63
64
use Symfony \Component \Routing \Loader \AnnotationDirectoryLoader ;
64
65
use Symfony \Component \Routing \Loader \AnnotationFileLoader ;
65
66
use Symfony \Component \Security \Core \Security ;
67
+ use Symfony \Component \Security \Csrf \CsrfTokenManagerInterface ;
8000
66
68
use Symfony \Component \Serializer \Encoder \DecoderInterface ;
67
69
use Symfony \Component \Serializer \Encoder \EncoderInterface ;
68
70
use Symfony \Component \Serializer \Mapping \Factory \CacheClassMetadataFactory ;
@@ -229,6 +231,11 @@ public function load(array $configs, ContainerBuilder $container)
229
231
$ this ->registerRequestConfiguration ($ config ['request ' ], $ container , $ loader );
230
232
}
231
233
234
+ if (null === $ config ['csrf_protection ' ]['enabled ' ]) {
235
+ $ config ['csrf_protection ' ]['enabled ' ] = $ this ->sessionConfigEnabled && !class_exists (FullStack::class) && interface_exists (CsrfTokenManagerInterface::class);
236
+ }
237
+ $ this ->registerSecurityCsrfConfiguration ($ config ['csrf_protection ' ], $ container , $ loader );
238
+
232
239
if ($ this ->isConfigEnabled ($ container , $ config ['form ' ])) {
233
240
if (!class_exists ('Symfony\Component\Form\Form ' )) {
234
241
throw new LogicException ('Form support cannot be enabled as the Form component is not installed. ' );
@@ -249,8 +256,6 @@ public function load(array $configs, ContainerBuilder $container)
249
256
$ container ->removeDefinition ('console.command.form_debug ' );
250
257
}
251
258
252
- $ this ->registerSecurityCsrfConfiguration ($ config ['csrf_protection ' ], $ container , $ loader );
253
-
254
259
if ($ this ->isConfigEnabled ($ container , $ config ['assets ' ])) {
255
260
if (!class_exists ('Symfony\Component\Asset\Package ' )) {
256
261
throw new LogicException ('Asset support cannot be enabled as the Asset component is not installed. ' );
0 commit comments