我将 LexikJWTAuthenticationBundle 与 Api-Platform 一起使用。我有多个这样的提供者:
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
当我使用候选防火墙“candidat/authentication_token”获取令牌时它正在工作,但是当我使用带有授权标头的令牌时,它正在使用主防火墙而不是候选者加载用户。
捆绑包如何知道仅通过令牌使用哪个防火墙?
如何与多个供应商打交道?
提前感谢您的帮助!
答案 0 :(得分:1)
Symfony 每个请求只使用一个防火墙,它是第一个与模式匹配的防火墙。因此,在您的情况下,它对 ^/candidat/authentication_token url 使用候选防火墙,并且其他请求与候选模式不匹配,他们将使用“main”。