如何在Symfony2 Security simple_preauth防火墙中使用多个身份验证器
我们正在建设一个Symfony网站,它将为移动应用程序公开REST API,但带有身份验证令牌,这将自动调整开发人员使用API的大小,对于此功能,我使用的是如何在Symfony2 Security simple_preauth防火墙中使用多个身份验证器,security,symfony,authentication,firewall,Security,Symfony,Authentication,Firewall,我们正在建设一个Symfony网站,它将为移动应用程序公开REST API,但带有身份验证令牌,这将自动调整开发人员使用API的大小,对于此功能,我使用的是simple_preauth防火墙身份验证程序,它工作正常。防火墙配置: firewalls: app_authenticated: pattern: ^/api context: app stateless: true simple_preauth:
simple_preauth
防火墙身份验证程序,它工作正常。防火墙配置:
firewalls:
app_authenticated:
pattern: ^/api
context: app
stateless: true
simple_preauth:
authenticator: api_key_authenticator
但我们的移动应用程序将提供最终用户登录,我们需要用户的会话是无状态的,这意味着,登录用户的令牌必须与开发者的令牌一起提供,如何在简单的预授权防火墙索引下实现多重认证器?
我尝试提供
[api\U key\U authenticator,api\U key\U authenticator 2]
作为2个身份验证程序,但简单的预授权。身份验证程序要求值为标量,而不是数组。有什么帮助吗?只有在Symfony 2.8使用Guard身份验证后才有可能:
为什么您的验证器不能同时处理开发者和用户令牌?我的ApiKeyAuthenticator中的
authenticateToken
方法似乎只在防火墙中配置时调用一次,并返回一个PreAuthenticatedToken
实例。因此,我无法验证其中的另一个密钥。
firewalls:
other_user_access:
pattern: ^/api/user/email$
guard:
authenticators:
- dev_authenticator
- api_prod_user_authenticator
- api_token_authenticator
entry_point: dev_authenticator