Symfony sfGuardUser在多个子域上的单一身份验证 [英] Symfony sfGuardUser single authentication on several subdomains

查看:63
本文介绍了Symfony sfGuardUser在多个子域上的单一身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将symfony 1.4.20与sfGuardUser插件一起使用。我有几个共享同一应用程序的子域。

I'm using symfony 1.4.20 with the sfGuardUser plugin. I have several subdomains that are sharing the same app.

该应用程序的一个模块应根据用户是否登录来提供稍有不同的内容。该模块应通过子域(例如sub.domain.com)进行访问。
现在,如果我通过domain.com访问此模块,则可以使用。如果我通过sub.domain.com访问模块,则即使用户登录也被视为未登录。

One module of the app should serve a slightly different content according the user is logged in or not. This module should be accessed through a subdomain, say sub.domain.com. Right now, if I access this module through domain.com, this works. If I access the modules through sub.domain.com, the user is seen as not logged in even if he is.

我的猜测是sfguad使用的auth cookie插件缺少域:.domain.com参数。我该如何改变?
此线程 3207099 似乎表明有可能。

My guess is the auth cookie used by the sfguad plugin is missing a Domain: .domain.com parameter. How can I change that? This thread 3207099 seems to indicate that it is possible.

谢谢!

推荐答案

我找到了解决方案。将session_cookie_domain参数添加到/ apps / my_app / config下的factory.yml文件中,例如:

I found the solution. Add the session_cookie_domain parameter in the factories.yml file under /apps/my_app/config like:

  storage:
    class: sfSessionStorage
    param:
      session_name: symfony
      session_cookie_domain: '.domain.localhost'

我很困惑,因为


  • 我首先认为这与
    使用的auth cookie有关sfGuard插件,但配置会话cookie的域足以实现我想要的
    。有人可以解释为什么吗?

  • 我对本地测试
    使用了仅一个单词的域,并且设置 .domain并没有出现在Cookie的域中。看起来
    必须至少是一个域,而tld必须是‘.domain.localhost’。

这篇关于Symfony sfGuardUser在多个子域上的单一身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆