Symfony 3.0.7
我尝试全局禁用csrf保护:
framework:
csrf_protection: false
然后我有例外:
Symfony \ Component \ DependencyInjection \ Exception \ ServiceNotFoundException:服务" security.firewall.map.context.main"依赖于不存在的服务" security.csrf.token_manager"。
但是服务" security.csrf.token_manager"如果我尝试直接在代码中使用它,则存在。
完整错误回溯:
Symfony \ Component \ DependencyInjection \ Exception \ ServiceNotFoundException:服务" security.firewall.map.context.main"依赖于不存在的服务" security.csrf.token_manager"。
/var/www/studio.lc/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:58 /var/www/studio.lc/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:42 /var/www/studio.lc/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:53 /var/www/studio.lc/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:51 /var/www/studio.lc/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:42 /var/www/studio.lc/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:36 /var/www/studio.lc/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php:104 /var/www/studio.lc/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:545 /var/www/studio.lc/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:477 /var/www/studio.lc/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:117 /var/www/studio.lc/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php:146 /var/www/studio.lc/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php:33 /var/www/studio.lc/src/Studio/Bundle/AdminBundle/Tests/Controller/SecuredAreaControllerWebTestCase.php:21
我该如何解决?
答案 0 :(得分:1)
这是config.yml中的以下语法:
csrf_protection:
enabled: false
如果您只是转到security.yml文件并从form_login指令中删除csrf_provider或csrf_token_generator。