如何能在根束security.yml使用服务从包

时间:2019-01-31 04:51:03

标签: symfony service dependency-injection

我正在尝试使用根捆绑软件中属于另一个捆绑软件的服务,但它抛出一个错误,我无法修复

在我的核心捆绑包中,在security.yml文件中,我正在使用lexik jwt库,并且必须将用户提供程序传递给它。我在不同的束在services.yml定义的用户提供者,我已经配置该束和控制台正确地找到它。当我从核心捆绑包中调用该服务时,就会发生错误,控制台会说找不到它会抛出一个错误

这是控制台错误:

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

这是我的security.yml:

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

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username
    firewalls:
        login:
            pattern:  ^/signin
            stateless: true
            anonymous: true
            form_login:
                check_path:               /signin
                success_handler:          lexik_jwt_authentication.handler.authentication_success
                failure_handler:          lexik_jwt_authentication.handler.authentication_failure
                require_previous_session: false
        language_culture:
            pattern: ^/languageCultures
            security: false

        webooks:
            pattern: ^/webhooks
            security: false

        api:
            pattern: ^/
            security: true
            stateless: true
            provider: api_bundle.security.auth_user_provider
            guard:
                authenticators:
                    - lexik_jwt_authentication.jwt_token_authenticator

        default:
            pattern: ^/
            anonymous: true
            logout:
                path: /logout
                target: /
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

    access_control:
        - { path: ^/signin, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/,       roles: IS_AUTHENTICATED_FULLY }

,这是我ApiBundle service.yml:

services:

    api_bundle.security.auth_user_provider:
        class: Yey\ApiBundle\Security\AuthUserProvider
        arguments:
            - '@yey.core.repository.user'
        public: true

我的配置有什么问题?

0 个答案:

没有答案