子域认证

发布于 2024-10-04 16:36:33 字数 295 浏览 4 评论 0原文

我正在使用默认的 ASP.NET 身份验证解决方案。现在我的服务器上有子域(例如 example.com、blog.example.com、forum.example.com...)登录发生在 example.com 上,并给出身份验证 cookie。但是当我访问 forum.example.com 时,我被重定向到登录。是否有配置设置可以使 *.example.com 登录有效?

值得注意的是,cookie 是作为域的“example.com”发布的。所以我根据一些阅读将其更改为“.example.com”,现在子域身份验证可以工作。有谁能解释一下吗?

I am using the default ASP.NET authentication solution. Now I have subdomains on my server (eg. example.com, blog.example.com, forum.example.com...) The login occurs on example.com, and gives out an authentication cookie. But when I go to forum.example.com I am redirected to login. Is there a configuration settings to making the login work for *.example.com?

It's worth noting that the cookies are issued as "example.com" for the domain. So I changed it to ".example.com" based on some reading, and now sub-domain authentication works. Anyone able to explain?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

强辩 2024-10-11 16:36:33

根据 RFC 2109,如果您不在域上加前缀点,则无效并且 cookie 应该被拒绝。
来自 RFC 2109

域名=域名
选修的。 Domain 属性指定了该域
cookie 有效。明确指定的域必须始终启动
带点。

4.3.2  Rejecting Cookies

   To prevent possible security or privacy violations, a user agent
   rejects a cookie (shall not store its information) if any of the
   following is true:

   * The value for the Path attribute is not a prefix of the request-
     URI.

   * The value for the Domain attribute contains no embedded dots or
     does not start with a dot.

According to RFC 2109, if you do not prefix a dot on the domain, it is invalid and the cookie should be rejected.
From RFC 2109

Domain=domain
Optional. The Domain attribute specifies the domain for which the
cookie is valid. An explicitly specified domain must always start
with a dot.

4.3.2  Rejecting Cookies

   To prevent possible security or privacy violations, a user agent
   rejects a cookie (shall not store its information) if any of the
   following is true:

   * The value for the Path attribute is not a prefix of the request-
     URI.

   * The value for the Domain attribute contains no embedded dots or
     does not start with a dot.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文