我按照说明创建自定义身份验证提供程序:http://symfony.com/doc/current/cookbook/security/custom_authentication_provider.html
app/config/安全:
firewalls:
wsse_protection:
pattern: ^/api/.*
wsse: true
main:
pattern: ^/
form_login:
provider: fos_userbundle
logout: true
anonymous: true
现在我在控制器中有一些带有路由的动作。例句:
ExampleController with listAction
路由:
example_list:
pattern: /example/list
defaults: { ... }
我必须复制所有路由到example_api_list吗?因为api/example/list不起作用(没有找到/api/example/list的路由)。我认为来自防火墙的模式是所有已定义路由的前缀
防火墙不是一个前缀,它是一个匹配传入路由的正则表达式。在这种情况下,任何以/api
开头的内容都将与您的wsse_protection
防火墙匹配,而所有未通过的内容将与您的main
防火墙匹配。
要在/api/*下创建路由,必须单独定义路由。