服务“security.authentication.manager”依赖于不存在的服务“security.user.provider.concrete.fos_userbundle”

时间:2015-03-25 19:39:36

标签: symfony sonata-user-bundle fosoauthserverbundle

我遇到了一个非常令人沮丧的问题,甚至不知道在哪里进行故障排除,因为Symfony没有提到罪犯。

我需要构建一个OAUTH服务器,以便在已经使Sonata User Admin / FOSUser捆绑包完美运行的应用程序上对移动用户进行身份验证。

我选择安装FOSOAuthServerBundle,我之前使用过,没有太多麻烦。今天,我不断收到以下错误:

 [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
 The service "security.authentication.manager" has a dependency on a non-existent service "security.user.provider.concrete.user_provider".

以下是我的相关文件:

config.yml

fos_user:
    db_driver:      orm # can be orm or odm
    firewall_name:  main
    user_class:     Application\Sonata\UserBundle\Entity\User

    group:
        group_class:   Application\Sonata\UserBundle\Entity\Group
        group_manager: sonata.user.orm.group_manager                    

    service:
        user_manager: sonata.user.orm.user_manager

fos_oauth_server:
    db_driver: orm
    client_class:        AppBundle\Entity\Client
    access_token_class:  AppBundle\Entity\AccessToken
    refresh_token_class: AppBundle\Entity\RefreshToken
    auth_code_class:     AppBundle\Entity\AuthCode
    service:
        user_provider:  sonata.user.orm.user_manager
        options:
            supported_scopes: user

security.yml

providers:
    fos_userbundle:
        id: fos_user.user_manager

encoders:
    FOS\UserBundle\Model\UserInterface: sha512    

firewalls:

    dev:
        pattern: ^/(_(profiler|wdt|error)|css|images|js)/
        security: false

    oauth_token:
        pattern:    ^/oauth/v2/token
        security:   false

    admin:
        pattern:            /admin(.*)
        context:            user
        form_login:
            provider:       fos_userbundle
            login_path:     /admin/login
            use_forward:    false
            check_path:     /admin/login_check
            failure_path:   null
        logout:
            path:           /admin/logout
        anonymous:          true

    oauth_authorize:
        pattern:    ^/oauth/v2/auth
        form_login:
            provider: user_provider
            check_path: _security_check
            login_path: _demo_login
        anonymous: true

    api:
        pattern:    ^/api
        fos_oauth:  true
        stateless:  true

    main:
        pattern:             .*
        context:             user
        form_login:
            provider:       fos_userbundle
            login_path:     /login
            use_forward:    false
            check_path:     /login_check
            failure_path:   null
        logout:             true
        anonymous:          true

这里有一个几乎相似的问题The service "security.authentication.manager" has a dependency on a non-existent service "security.user.provider.concrete.fos_userbundle",但他的问题是通过在提供商下省略fos_userbundle id来实现的,这种情况就是我的情况。

有人请协助解决问题

1 个答案:

答案 0 :(得分:4)

您的错误必须在此处:

oauth_authorize:
        pattern:    ^/oauth/v2/auth
        form_login:
            provider: user_provider #where is this provider? shouldnt it be fos_userbundle
            check_path: _security_check
            login_path: _demo_login
        anonymous: true