gpt4 book ai didi

php - 将 Zend 1 包装到 Symfony 2 中。如何共享 session ?

转载 作者:可可西里 更新时间:2023-10-31 23:47:55 25 4
gpt4 key购买 nike

在我的工作中,我们正在努力将 Zend 1 应用程序迁移到 Symfony 2。我试图弄清楚如何无害地完成这项工作。我找到了以下 SF2 bundle :https://github.com/mainlycode/Zf1WrapperBundle .我安装了它,按照配置说明进行操作,将我的 Zend 应用程序复制到/vendor/zend 中,一切正常。当我浏览我的旧登录路由时,SF2 无法理解并询问 Zend 的响应,然后出现我的登录表单。我可以登录,并且可以正常工作,网站的授权部分显示正确。

现在我想开始修改需要对用户进行授权的功能。所以我创建了一个新的 SF2 包,称为 BackendBundle。它在我的 Controller 中尝试了这个:

$securityContext = $this->container->get('security.context');
if( $securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED') ){
echo 'AUTHED';
}

但是我得到以下错误:

The security context contains no authentication token. One possible reason may be that there is no firewall configured for this URL. 

我完全理解为什么。但我真的不知道如何“共享”Zend 和 SF2 之间的身份验证。有什么建议吗?

最佳答案

我的第一个猜测是共享 session (将 ZF 和 Sf2 配置为使用类似的 SessionHandler),但是 Sf2 以非常特殊的方式存储 session 信息,ZF 可能不会轻易支持。

但我想您可以尝试创建一个 Sf2 RequestListener 来读取您的 ZF session ,在其中找到一个授权 token ,然后创建一个 Sf2 授权 token 以最终将其注入(inject) SecurityContext。

你怎么看?

关于php - 将 Zend 1 包装到 Symfony 2 中。如何共享 session ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24657454/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com