21

I trying to enable FOSUserBundle as well as FOSFacebookBundle.
I've got an exception at any url.

Any ideas guys?

ServiceNotFoundException: The service "security.authentication.manager" has a dependency on a non-existent service "security.user.provider.concrete.fos_userbundle"

config.yml

fos_user:
    db_driver: mongodb
    firewall_name: main
    user_class: Acme\AcmeBundle\Document\User
fos_twitter:
    file: %kernel.root_dir%/../vendor/twitteroauth/twitteroauth/twitteroauth.php
    consumer_key:    ''
    consumer_secret: ''
    callback_url: ''
fos_facebook:
    file:   %kernel.root_dir%/../vendor/facebook/src/base_facebook.php
    alias:  facebook
    app_id: ''
    secret: ''
    cookie: true
    permissions: [email, user_birthday, user_location]
services:
    my.facebook.user:
        class: Acme\AcmeBundle\Security\FacebookProvider
        arguments:
            facebook: "@fos_facebook.api"
            userManager: "@fos_user.user_manager"
            validator: "@validator"
            container: "@service_container"





security:       
    factories:
      - "%kernel.root_dir%/../vendor/bundles/FOS/TwitterBundle/Resources/config/security_factories.xml"
      - "%kernel.root_dir%/../vendor/bundles/FOS/FacebookBundle/Resources/config/security_factories.xml"

    providers:
        my_fos_facebook_provider:
            id: my.facebook.user                     

    firewalls:       
        public:
          pattern:   ^/.*
          form_login:
            login_path: /login
            provider: fos_userbundle          
          fos_facebook:
            app_url: ""
            server_url: ""
            login_path: /login
            check_path: /login_check/facebook
            provider: my_fos_facebook_provider
          anonymous: true
          logout:    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 }

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]  
synthetic
  • 798
  • 1
  • 7
  • 20

3 Answers3

30

I added fos_userbundle id to providers section and it works fine now.

providers:
    my_fos_facebook_provider:
        id: my.facebook.user  
    fos_userbundle:
        id: fos_user.user_manager
synthetic
  • 798
  • 1
  • 7
  • 20
  • 3
    Use of `fos_user.user_manager` is _deprecated_. Better use `fos_user.user_provider.username` [source](https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/user_manager.md#securitybundle-integration) – KmeCnin Jul 16 '15 at 21:02
  • I just got this error. But your problem wasn't the id. But you forgot to set your provider name (`fos_userbundle`) in your firewall `form_login.provider` – user3502626 Jul 14 '17 at 20:16
1

For symfony3

providers:
    in_memory:
        memory: ~
    fos_userbundle:
      id: fos_user.user_provider.username
Tim Lieberman
  • 571
  • 2
  • 5
  • 23
0

I tried all provided solutions in stackoverflow, but none worked for me.
My solution was to rename fos_userbundle to fos_user in security: providers: section and in security: firewalls: main: form_login: provider:.
Hope this can help someone out there.

Takman
  • 1,028
  • 10
  • 13