【发布时间】:2018-01-16 15:09:40
【问题描述】:
我有一个 symfony 2.8 应用程序,将用作 REST API 后端
我想为所有匹配 ^/api 的端点添加安全性 我希望能够为 ^/api
使用 3 种不同的身份验证方法我正在使用 uma/psr7-hmac-bundle、friendsofsymfony/oauth-server-bundle、APIKey 身份验证。
我定义了 3 个不同的防火墙,如果我删除其他两个防火墙,每个防火墙都可以正常工作。
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
oauth_token:
pattern: ^/oauth/v2/token
security: false
oauth_authorize:
pattern: ^/oauth/v2/auth
security: false
api_key:
pattern: ^/api
stateless: true
simple_preauth:
authenticator: api_key_authenticator
provider: api_key_user_provider
oauth_api:
pattern: ^/api
stateless: true
fos_oauth: true
provider: oauth_user
hmac_api:
pattern: ^/api
stateless: true
hmac:
apikey_header: 'X-Custom-Header-Key'
provider: hmac_user
如何同时使用所有 3 个防火墙(链接它们)? (hmac_api, oauth_api, api_key)
我研究了 Guards,但我不确定如何为 HMAC 和 oAuth 定义/实现身份验证器。
我查看了防火墙上下文,但因为它是无状态的,所以它不起作用。
基本上,我怎样才能为相同的模式链接多个防火墙?或者考虑到我正在使用诸如friendsofsymfony/oauth-server-bundle、uma/psr7-hmac-bundle之类的第三方捆绑包,我该如何定义一个具有3个不同身份验证器的防火墙?
【问题讨论】:
标签: symfony oauth hmac api-key symfony-security