ASP.NET 跨域 Cookie 和脸书连接

发布于 2024-09-10 16:50:50 字数 1063 浏览 6 评论 0原文

我有一个与 Facebook 集成的网站(通过 FBML - JavaScript API)。

我已按照正常方式在 Facebook 上设置应用程序,并将“连接 URL”指定为我的网站的域。

但是,我的应用程序在 IIS 中对同一网站有多个绑定

例如:

www.bar.com.au

foo.com.au

这些域完全不同,名称中没有任何关系 - 因此不可能使用正则表达式样式的规则(即基域)。由于本地化和营销的结合,这些域名变得不同。请记住,这些域已嵌入到已经上线的网站中,换句话说,我无法更改此架构。

有没有办法可以在“连接 URL”的 一个 Facebook 应用程序设置中指定这些域的两个?或者我必须创建多个应用程序?

当然,我不能使用“基域”设置,因为绑定不在同一子域上。

实际上,我的网站中有大约 7 个绑定 - 所以我不想创建 7 个单独的 Facebook 应用程序 - 因为这意味着在我的应用程序中维护 7 组 API 密钥/秘密对。

替代文本 http://www.freeimagehosting.net/uploads/268b234e2f.png

什么当然,当我访问 foobar.com.au 时,该域无法使用 Facebook cookie。

与此同时,我将尝试创建多个 ApiKey - 但我认为我可能会遇到问题。我将不得不说:“如果域是这个,则使用这个 ApiKey”,然后在对 Graph API 的每次调用中都使用相同的逻辑。乱七八糟的东西。

所以我想我的问题并不是真正由 Facebook Connect 引起的,而是 HTTP Cookie 设计的本质。

我如何轻松跨域访问这些cookie?我需要设置第三网站并将所有 cookie 逻辑定向到那里吗?

I have a website which i integrate with Facebook (via FBML - JavaScript API).

I have setup the application on Facebook as per normal, specifying the "Connect URL" to be the domain of my website.

However, my application has multiple bindings in IIS for the same website.

Such as:

www.bar.com.au

foo.com.au

The domains are completely different, no relationship in the name whatsoever - so a regex-style rule is not possible (ie base domain). The domains were made different due to a combination of localization and marketing. Keep in mind these domains are baked in to an already live website, in other words i cannot change this architecture.

Is there a way i can specify BOTH of these domain's in the ONE Facebook Application settings for the "Connect URL"? Or will i have to create multiple applications?

Of course i cannot use the "Base Domain" setting as the bindings are not on the same sub-domain.

I actually have around 7 bindings in my website - so i'd rather not have to create 7 seperate Facebook applications - because this means maintaining 7 sets of API key/secret pairs in my application.

alt text http://www.freeimagehosting.net/uploads/268b234e2f.png

What's happening of course is when im on foobar.com.au, the Facebook cookies are not available to the domain.

For the meantime, i will try and create multiple ApiKey's - but i think i might run into issues. I'm going to have to go: "If domain is this, use this ApiKey", then the same logic in every single call to the Graph API. Messy stuff.

So i guess my problem/question isn't really caused by Facebook Connect, its the nature of HTTP Cookies by design.

How can i easily access these cookies cross domain? Will i need to setup a third website and direct all cookie logic to there?

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

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

发布评论

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

评论(3

陌生 2024-09-17 16:50:50

如果您希望允许 *.foobar.com.au,请将您的基域设置为 foobar.com.au

If you want *.foobar.com.au to be allowed, then setup your Base Domain to foobar.com.au.

你的心境我的脸 2024-09-17 16:50:50

您能否将其中一个站点设置为您的“Facebook 身份验证”站点,并将所有与 FB 身份验证相关的流量定向到那里,然后使用大量跨站点通信技巧之一将令牌发送到原始站点?

换句话说,无论它们来自哪个网站,您都将使用 .foobar.com.au(例如)作为重定向 URI。然后,当他们进入该网站时,您注意到他们来自 .foo.bar.com.au,您会将他们重定向回他们来自的地方,以某种跨域方式传递访问令牌(查询字符串、帖子)变量等)

Could you set one of them up as your "Facebook Authentication" site, and direct all FB Auth-related traffic there, and then use one of a large number of cross-site communication tricks to send the token over to the original site?

In other words, regardless of the site they come in from, you'll use .foobar.com.au (for example) as the redirect URI. Then when they come in to that site with you having noted that they came from .foo.bar.com.au, you'll redirect them back where they came from passing along the access token in some cross-domain fashion (querystring, post vars, etc.)

祁梦 2024-09-17 16:50:50

在我目前的情况下,时间框架阻止了我采取正确的解决方案,这就是@Yuliy 所强调的。

目前,我已经创建了多个 Facebook 应用程序。但为了保持干燥,我将所有这些都抽象到了暴露的属性后面:

private static string _ApiToken_Site1, _ApiToken_Site2;
public static string ApiToken
{
   get
   {
       if (Site1) return _ApiToken_Site1;
       else if (Site2) return _ApiToken_Site2;
   }
}

不完全干净,但主要的是我根本不需要接触我现有的代码,明智地找出要使用哪个 Api Key 就在其中财产。

对于我们的下一个项目版本,我将放弃这一点,并最有可能实现一个 WCF/ASMX Web 服务,该服务从一个地方处理身份验证(即单独域上的单独 Web 服务)。

In my current situation, timeframes have stopped me from doing the proper solution, which is what @Yuliy has highlighted.

For now, i have created multiple Facebook applications. But to keep it DRY, i have abstracted all that away behind exposed properties:

private static string _ApiToken_Site1, _ApiToken_Site2;
public static string ApiToken
{
   get
   {
       if (Site1) return _ApiToken_Site1;
       else if (Site2) return _ApiToken_Site2;
   }
}

Not exactly clean, but the main thing is i did not have to touch my existing code at all, the smarts to work out which Api Key to use is in that property.

For our next project release, i'll be scrapping this and most likely implementing a WCF/ASMX web service which handles authentication from the one place (ie seperate web service on seperate domain).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文