在没有默认控制器/操作的情况下,登录 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.
从未真正访问过此路由的操作.这是您的登录表单发布到的路由/网址,并且该请求应由您的防火墙提供程序服务进行处理.
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屋!