将 Facebook 身份验证与现有 ASP.NET 成员资格集成
编码平台:使用 C# 的 ASP.NET 4.0 WebForms
我们有一个网站,其中现有的登录详细信息由 ASP.NET 会员提供商管理。
现在客户想要将 Facebook Connect 添加到其中。
因此,在注册时,我将使用 Facebook 按钮进行注册。
我该如何继续将 Facebook 的成功身份验证集成到我的会员提供商?
我计划是创建一个具有唯一标识符的用户名作为 ASP.NET 会员中的新用户,并将其链接到另一个包含其他开放 ID 用户的表(因为将来我们计划扩展到 Google、Twitter、Live 等) )。这是最好的方法吗?
Coding Platform: ASP.NET 4.0 WebForms with C#
We have a website with the existing login details managed by ASP.NET Membership Provider.
Now client wants to add Facebook Connect to it.
So on registration I am giving a Register using Facebook Button.
How shall I proceed with integrating a successful authentication from facebook to my membership provider?
What I am planning is to create a username with unique identifier as a new user in ASP.NET Membership and link that to another table that contains other open-id users(cos in future we plan to extend to Google, Twitter, Live and all). Is that the best method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
嗯,我认为你有两个选择。
选项A:
使用 Facebook 注册插件,然后将用户注册为普通用户,即不存储 FB 用户 ID数据库,您只有一种类型的用户。
选项B:
在您的 FB 连接中请求电子邮件权限并获取用户电子邮件,以便与您的用户表进行比较并做出匹配(您的用户表 ID 与 FB uid),以防在您的数据库中找到它。
哈!
Well, I think that you have two options here.
Option A:
Use the Facebook Registration Plugin and then get the user registered as a regular user i.e. no FB user id is stored into the db, you only have one type of user.
Option B:
Ask for email permission within your FB connect and get the user email in order to compare against your user table and make a match (your user table id with FB uid) in case it's found into your DB.
HTH!
等等,codeplex 上有 Facebook 开发者工具包吗?希望我知道这一点。 :-p
我注意到大多数允许您使用 Facebook 或电子邮件登录的网站只允许您选择其中之一。例如,我有一个 LivingSocial.com 帐户 - 尽管他们提供 FB,但我只能使用我的电子邮件登录(因为这就是我的帐户的创建方式)。我有一个 BrazenCareerist 帐户,但我只能使用我的 FB 登录(即使他们支持电子邮件),因为该帐户是通过 FB Connect/Open-Graph 创建的。
我不喜欢这种方法,因为它感觉有限制 - 所以我希望用户能够按照他们想要的方式登录。您有 4 个流程:
如果他们使用 Facebook 注册,请获取他们的电子邮件地址以供将来使用(通过 FB API)。
假设他们已经在您的网站上注册,那么当他们使用 FB 登录时,无需请求密码。 (检查他们的文档http://developers.facebook.com/docs/authentication/)
如果他们使用他们的电子邮件地址,他们需要输入密码。如果他们使用电子邮件地址注册,他们可能会创建;但诀窍是,如果他们用 FB 注册,他们可能没有密码。
我创建了一个页面,在注册 FB 时要求输入密码。它会给出一条友好的消息,例如“恭喜!您在 [我们的网站] 上的帐户已创建。为了您的隐私,Facebook 不会告诉我们您的密码是什么。请在下面为 [我们的网站] 创建一个密码。(只要您用 Facebook 登录,你永远不会使用这个)。”
希望有帮助。
Wait, there's a facebook developer toolkit on codeplex? Wish I'd known that. :-p
I've noticed that most sites that let you sign in with either Facebook or your Email will only let you do ONE OR THE OTHER. For example, I have a LivingSocial.com account - and although they offer FB I can only log on with my email (as that's how my account was created). I have a BrazenCareerist account, but that let's me log in ONLY with my FB (even though they support email) because the account was created via FB Connect/Open-Graph.
I didn't like that approach as it felt limiting - so I wanted users to be able to sign-in however they wanted. You have 4 flows:
If they sign up with facebook, grab their email address for future use (via the FB API).
Assuming they're signed up already on your site, then when they sign in with FB, there's no need request a password. (check their documentation http://developers.facebook.com/docs/authentication/)
If they sign in with their email address, they'll need to enter a password. They probably created on if they signed UP with their email address; but the trick is that if they signed up with FB they might NOT have a password.
I created a page that, upon FB sign up, asks for a password. It gives a friendly message like "Congrats! You account on [our site] is created. For your privacy, facebook doesn't tell us what your password is. Please create a password for [our site] below. (As long as you sign-in with facebook, you'll never use this)."
Hope that helps.
CodePlex 上的 Facebook C# SDK 项目提供了一些很棒的示例项目以供入门。我一直在使用的是 CS-AspNetWebForms-RegistrationForm Sample。它很容易理解,但我遇到了一些问题,例如获取 Facebook 用户 ID。
拼图中缺失的部分是获取从 Facebook 注册返回的那些字段并将其推送给会员提供商。根据您的经验水平,解决这个问题应该不难。
The Facebook C# SDK project on CodePlex offers some great sample projects to get started. The one I've been using is the CS-AspNetWebForms-RegistrationForm Sample. It's easy enough to follow, but am having a few issues like getting hold of the Facebook UserID.
The missing piece of the puzzle is taking those fields you get back from Facebook Registration and pushing those to the Membership Provider. Depending on your level of experience, it shouldn't be that hard to workt through.
恐怕我的答案会有点不稳定,因为我没有使用过它,也不知道它是否与 Facebook 集成。不过,您可能会对 Windows Identity Foundation 感兴趣:http://msdn.microsoft.com/ zh-cn/安全/aa570351
I'm afraid my answer is going to be a bit flakey, a I haven't used it nor know if it integrates with facebook. However Windows Identity Foundation may be of interest to you: http://msdn.microsoft.com/en-us/security/aa570351