使用Symfony 2,我正在寻找有关可以在安全配置文件app/config/security.yml
(正式文件)中定义的处理程序的更多信息。文档没有提供任何关于处理程序的信息。以下是安全文件的摘录:
# app/config/security.yml
security:
...
firewalls:
somename:
form_login:
...
# login failure redirecting options (read further below)
failure_path: /foo
failure_forward: false
failure_path_parameter: _failure_path
failure_handler: some.service.id
success_handler: some.service.id
logout:
path: /logout
target: /
invalidate_session: false
delete_cookies:
a: { path: null, domain: null }
b: { path: null, domain: null }
handlers: [some.service.id, another.service.id]
success_handler: some.service.id
anonymous: ~
在两个form_login和注销部分中都有一个success_handler
字段。此外,对于注销部分,可以使用handlers
字段定义几个处理程序。
我有两个问题:
succes_handler
服务(例如使用AuthenticationSuccessHandlerInterface或LogoutHandlerInterface),它会覆盖框架中提供的默认成功处理程序吗?handlers
字段如何工作?发布于 2015-02-13 08:24:50
有关信息,请参阅app/config/security.yml
的注销部分:
handlers: [some.service.id, another.service.id]
=>这里您必须定义实现Symfony\Component\Security\Http\Logout\LogoutHandlerInterface
的服务。这些句柄不需要返回响应。在我的例子中,我创建了一个简单的处理程序,在注销时创建一个闪存消息。
success_handler: some.service.id
=>在这里您必须定义一个实现=> Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface
的服务。这个处理程序必须返回一个响应。此处理程序由Symfony\Component\Security\Http\Firewall\LogoutListener
(防火墙侦听器)的构造函数调用。
发布于 2015-02-10 12:35:00
我成功地尝试了下一个解决方案,https://gist.github.com/marydn/8061424似乎就是您想要做的。
https://stackoverflow.com/questions/28427286
复制相似问题