如果没有默认控制器/操作,登录 check_path 路由如何工作? [英] How does the login check_path route work without default controller/action?
问题描述
我正在开发具有以下路由代码的 symfony 2.3 项目
I am working on symfony 2.3 project having the following routing code
just2_frontend_logincheck:
pattern: /login_check
没有
defaults:{ _controller: testBundle:User:login }
但它正在工作.但我不知道路由是如何工作的.是否可以?请告诉我有关路由的信息.
But it is working. But I don't know how the routing is working. Is it possible? Please advice me about the routing.
推荐答案
check_path 路由/路径被您的防火墙用来捕获登录请求.
The check_path route/path is used by your firewall to catch login requests.
这条路线的动作从未真正被访问过.这是您的登录表单发布到的路由/URL,并且该请求应由您的防火墙的提供商服务处理.
This route's action is never really accessed. It's the route/url your login form posts to and the request should be processed by your firewall's provider service.
如果 check_path
路由的操作正在执行,则说明防火墙有问题(您的防火墙未处理该请求).
If the check_path
route's action is being executed there is something wrong with the firewall (the request is not processed by your firewall).
如您所见,这里 FOSUserBundle"scheck_path 被路由到 SecurityController::checkAction
并且只是抛出一个 RuntimeException
.
As you can see here FOSUserBundle"s check_path is routed to SecurityController::checkAction
and just throws a RuntimeException
.
check_path的配置可以在security.firewalls.
下的app/config/security.yml
中找到.
The configuration of the check_path can be found in app/config/security.yml
under security.firewalls.<firewallname>.form_login.check_path
.
它可以是 /login_check
之类的模式,也可以是路径名称,即 just2_frontend_logincheck
但没有基础操作.
It can either be a pattern like /login_check
or as in your case a route name i.e. just2_frontend_logincheck
but there is no underlying action.
security:
providers:
your_provider_name: your_provider_service # authentication provider
# ...
firewalls: # Required
your_firewall_name:
# ...
provider: your_provider_name
form_login:
check_path: /login_check # submit the login form here
# in your case a route name:
# just2_frontend_logincheck
在后台,symfony 调用服务 your_provider_service
的 authenticate()
方法来检查提供的凭据.
Under the hood symfony calls the authenticate()
method of the service your_provider_service
to check the credentials provided.
您可以使用以下方法找到用作提供者服务的类:
You can find the class used as the provider-service using:
app/console debug:container --show-private your_provider_service
这篇关于如果没有默认控制器/操作,登录 check_path 路由如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!