问题
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:
- You have configured FOSU from cookbook from symfony.com, which now is outdated for FOSU 2.0+. Solution:
csrf_token_generator
Instead ofcsrf_provider
in security.yml
- You have not enabled csrf in config.yml
framework: csrf_protection: enabled: true
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