在 Symfony 2 中找不到多个防火墙的 check_path [英] check_path not found with multiple firewalls in Symfony 2
问题描述
我正在尝试在 Symfony 2 中设置后端和前端防火墙系统.我有两个登录表单,一个用于前端,另一个用于管理控制面板.不同的供应商等等.我的配置如下:
I'm trying to setup a backend and frontend firewall system in Symfony 2. I have two login forms, one for the frontend and another one for the admin control panel. Different providers and so on. My configuration looks like this:
security:
firewalls:
backend:
pattern: ^/admin
anonymous: true
provider: admin_users
form_login:
login_path: /admin/login
check_path: /admin/login_check
default_target_path: /admin
secured_area:
pattern: ^/
provider: normal_users
anonymous: true
form_login: ~
access_control:
- { path: ^/admin/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin, roles: ROLE_ADMIN }
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
还有我的routing.yml:
And my routing.yml:
login:
path: /login
defaults: { _controller: MyFrontendBundle:Default:login }
login_check:
path: /login_check
admin_login:
path: /admin/login
defaults: { _controller: MyBackendBundle:Default:login }
admin_login_check:
path: /admin/login_check
似乎正确,但我遇到以下错误:无法找到路径/admin/login_check"的控制器.也许你忘记在路由配置中添加匹配的路由
Seems right, but i'm having the following error: Unable to find the controller for path "/admin/login_check". Maybe you forgot to add the matching route in your routing configuration
有什么想法吗?:)
推荐答案
删除/"可能不错,因此您只有:
Might not be bad just to remove the "/" so you only have :
login_path: admin/login
check_path: admin/login_check
default_target_path: admin
让模式属性保持原样.这实际上是我的 security.yml
的样子并且可以解释路由问题.
And let the pattern attribute the way it is. This is actually how my security.yml
looks like and would explain the route problem.
这篇关于在 Symfony 2 中找不到多个防火墙的 check_path的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!