没有默认的控制器/动作,登录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.
推荐答案
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" s的check_path被路由到SecurityController::checkAction
并仅抛出RuntimeException
.
As you can see here FOSUserBundle"s check_path is routed to SecurityController::checkAction
and just throws a RuntimeException
.
可以在security.firewalls.<firewallname>.form_login.check_path
下的app/config/security.yml
中找到check_path的配置.
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屋!