【发布时间】:2013-04-03 06:11:56
【问题描述】:
当 symfony2 通过登录表单对用户进行身份验证时,会触发一个事件 security.authentication.success 并由 DefaultAuthenticationSuccessHandler 处理。这个对象的构造函数有两个参数HttpUtils $httpUtils 和array $options。变量$options 不为空,包含来自security.yml 的配置选项,例如:
login_path => pkr_blog_admin_login
user_referer => false
...
我创建了一个服务AuthenticationSuccessHandler,它扩展了DefaultAuthenticationSuccessHandler,但找不到将值从security.yml 作为$options 传递给我的对象的构造函数的方法。我该怎么做?
我曾尝试使用 xdebug 逐步调试来查看这些选项如何传递给 DefaultAuthenticationSuccessHandler,但在代码中找不到确切位置:/
//编辑
我发现此配置是在src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php 中设置的,并且仅适用于默认处理程序。
这里有一些关于在自定义处理程序中没有从 security.yml 获取配置的 cmets:
https://github.com/symfony/symfony/issues/5432
https://github.com/symfony/symfony/issues/5488
任何人都知道如何从我的处理程序中获取配置解析并准备好使用默认处理程序?
我想这可以通过将服务容器传递给我的处理程序来完成。我下班回来试试这个。
【问题讨论】:
标签: authentication symfony service