Symfony 具有多个提供程序的LexikJWTAuthenticationBundle

Symfony 具有多个提供程序的LexikJWTAuthenticationBundle,symfony,api-platform.com,lexikjwtauthbundle,Symfony,Api Platform.com,Lexikjwtauthbundle,我在Api平台上使用LexikJWTAuthenticationBundle。我有多个这样的提供商: providers: app_user_provider: entity: class: App\Entity\User property: email app_candidat_provider: entity: class: App\Entity\Candidat

我在Api平台上使用LexikJWTAuthenticationBundle。我有多个这样的提供商:

providers:
    app_user_provider:
        entity:
            class: App\Entity\User
            property: email

    app_candidat_provider:
        entity:
            class: App\Entity\Candidat
            property: email
            
firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false

    candidat:
        pattern: ^/candidat/authentication_token
        anonymous: true
        lazy: true
        stateless: true
        provider: app_candidat_provider
        json_login:
            check_path: /candidat/authentication_token
            username_path: email
            password_path: password
            success_handler: lexik_jwt_authentication.handler.authentication_success
            failure_handler: lexik_jwt_authentication.handler.authentication_failure
        guard:
            authenticators:
                - lexik_jwt_authentication.jwt_token_authenticator

    main:
        anonymous: true
        lazy: true
        stateless: true
        provider: app_user_provider
        json_login:
            check_path: /authentication_token
            username_path: email
            password_path: password
            success_handler: lexik_jwt_authentication.handler.authentication_success
            failure_handler: lexik_jwt_authentication.handler.authentication_failure
        guard:
            authenticators:
                - lexik_jwt_authentication.jwt_token_authenticator
当我使用Candidate firewall“Candidate/authentication_token”获取令牌时,它会工作,但当我使用带有授权头的令牌时,它会使用主防火墙而不是Candidate加载用户

捆绑包如何知道仅与令牌一起使用哪个防火墙

如何处理多个供应商


提前感谢您的帮助

Symfony每个请求只使用一个防火墙,这是第一个与该模式匹配的防火墙。因此,在您的情况下,它对^/candidate/authentication\u令牌URL使用Candidate防火墙,而其他请求与Candidate模式不匹配,它们将使用“main”。

是,它可以工作,谢谢