Majdi Allagui
Majdi Allagui

Reputation: 11

csrf error FOSUserBundle

im using symfony 3.4.4 i tried to install fosuserbundle following the FOSUser docs: https://symfony.com/doc/master/bundles/FOSUserBundle/index.html

When I execute the command:

bin/console doctrine:schema:update --force

I received this error:

The service "security.authentication.listener.form.main" has a dependency on a non-existent service "security.csrf.token_manager"

Is there any solution?

config yml

framework:
    csrf_protection: ~
    #esi: ~
    translator: { fallbacks: ['%locale%'] }
    secret: '%secret%'
    router:
        resource: '%kernel.project_dir%/app/config/routing.yml'
        strict_requirements: ~
    form: { enabled: false }
    csrf_protection: { enabled: false }
    validation: { enable_annotations: true }
    serializer: { enable_annotations: true }
    templating:
        engines: ['twig']
    default_locale: '%locale%'
    trusted_hosts: ~
    session:
        # http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
        handler_id: session.handler.native_file
        save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'
    fragments: { enabled: false }
    http_method_override: true
    assets: ~
    php_errors:
        log: true

security yml

security: encoders: FOS\UserBundle\Model\UserInterface: bcrypt

role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: ROLE_ADMIN

providers:
    fos_userbundle:
        id: fos_user.user_provider.username

firewalls:
    main:
        pattern: ^/
        form_login:
            provider: fos_userbundle
            csrf_token_generator: security.csrf.token_manager

        logout:       true
        anonymous:    true

access_control:
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/, role: ROLE_ADMIN }

Upvotes: 1

Views: 514

Answers (1)

ozahorulia
ozahorulia

Reputation: 10084

framework:
    csrf_protection: ~

Docs on that page are outdated. This issue will be fixed soon in symfony/symfony #25808

More info about this error: https://github.com/FriendsOfSymfony/FOSUserBundle/issues/2705

Upvotes: 1

Related Questions