Unrecognized options “csrf_provider” under “security.firewalls.form_login”

两盒软妹~` 提交于 2019-12-08 17:11:53

问题


I'm trying to install the FOSUserBundle following the tutorial here

When I'm at the 7th step I try to update the database schema for ORM running

php app/console doctrine:schema:update --force

but appears the error

InvalidConfigurationException: Unrecognized options "csrf_provider" under "security.firewalls.form_login"

Here's my firewall:

firewalls:
        main:
        pattern: 
        form_login:
            provider: fos_userbundle
            csrf_provider: form.csrf_provider
        logout:       true
        anonymous:    true

What can I do? I don't set a pattern because, if I set something like

        pattern: ^/

the following error appears:

InvalidTypeException: Invalid type for path "security.firewalls.pattern". Expected array, but got string

UPDATE:

The csrf_protection was enable but, for some reason that I don't understand, didn't work. I tried to "reset" it, disabling and enabling, and now it works. In my project I enable it with

csrf_protection: ~

回答1:


You need to enable csrf protection. You can do that by adding a key to the config.yml

framework:
    csrf_protection:
        enabled: true



回答2:


in security.yml

for sloving this problem you just need to comment this command :

csrf_token_generator: security.csrf.token_manager

and enable this comment instead :

csrf_provider: form.csrf_provider




回答3:


There can be 3 main reasons for this problem:

  1. You have configured FOSU from cookbook from symfony.com, which now is outdated for FOSU 2.0+. Solution:

csrf_token_generator Instead of
csrf_provider

in security.yml
  1. You have not enabled csrf in config.yml framework: csrf_protection: enabled: true
  2. You didn't update AppKernel.php with:

    new FOS\UserBundle\FOSUserBundle(),

    Maybe all at once. Good luck :)



来源:https://stackoverflow.com/questions/20350330/unrecognized-options-csrf-provider-under-security-firewalls-form-login

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!