如何保留 ASP.NET Forms 身份验证 cookie、Http 到 Https(不同域)以及返回的身份验证?
我们有一个非 SSL ASP.NET Web 应用程序,允许用户登录(ASP 表单身份验证、inproc)。
经过身份验证后,我们会将他们的浏览器重定向到我们无法控制的另一个网站/域上的外部 SSL 安全页面。
完成后,客户端将重定向回我们原始 http Web 应用程序上预先配置的 URL。
然而,客户随后被要求在我们这边再次“重新登录”,这是不希望的...
在 HTTP 和 HTTPS 之间转换并再次转换回来时,表单身份验证 cookie 似乎被破坏了。
如何使表单身份验证 cookie 保持活动状态,以便客户无需在往返过程中重新进行身份验证?
We have a non-SSL ASP.NET web app that allows a user to login (ASP forms authentication, inproc).
Once authenticated, we redirect their browser to an external, SSL secured page on another web site / domain altogether that we do not control.
The client is redirected back to a pre-configured url on our original http web app when done.
However, the customer is then asked to "re-login" again on our side which is undesired...
It seems the forms authentication cookie is destroyed when transitioning between HTTP and HTTPS and back again.
How can I keep the forms authentication cookie alive so that the customer does not have to re-authenticate on the round trip?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它并没有被摧毁;而是被破坏了。您未在您的域上进行身份验证,因此未在您的域上设置 cookie,因此您的域上的请求将不会包含所述身份验证 cookie。
这很好。如果没有发生这种情况,那么您访问过的每个域中的每个 cookie 都会随每个请求一起发送。这显然是 1) 疯狂和 2) 安全漏洞。在 mydomain.com 上设置的 cookie 应该永远对 myotherdomain.com 上的页面可见。
如果您使用第三方身份验证系统,例如 google、facebook 等,它们都会有某种回调令牌,您必须处理并设置自己的 cookie。
It's not being destroyed; you're not authenticating on your domain, so the cookie's not being set on your domain, and thus requests on your domain will not contain said authentication cookie.
This is GOOD. If this didn't happen, then every cookie from every domain you ever visited would get sent with every request. Which is obviously 1) crazy and 2) a security hole. Setting a cookie on mydomain.com should never be visible to pages on myotherdomain.com.
If you're using a 3rd party authentication system, like google, facebook, etc, they'll all have some sort of callback token that you'll have to process and set your own cookies.
考虑为您的 cookie 设置 cookie 的域属性,更具体的可以在这里找到 或尝试以下代码:
Consider to set cookie's domain property for your cookies with more specified can be found here or try this code:
您正在寻找单点登录解决方案。
对于您的问题来说,这可能有点过分了,您可能只想获得相同的域名。但如果这不是一个选择,您可能想看看:
Windows 身份基础
You're looking for a Single Sign On solution.
It might be a little overkill for your problem, for which you might just want to get the same domainname. But if that isn't an option you might want to take a look at:
Windows Identity Foundation