用于多重身份验证、Facebook Connect、Twitter、OpenID 等的数据库架构 [英] Database Schema for multiple authentications, Facebook Connect, Twitter, OpenID, etc

查看:44
本文介绍了用于多重身份验证、Facebook Connect、Twitter、OpenID 等的数据库架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个应用程序,我想将它与 Facebook Connect、Twitter、OpenID 以及其他可能的社交网络进行交互.用户将能够同时使用任意数量的这些方法登录.我的应用程序使用 MySQL 作为后端数据库.

I am building an application that I want to interface with Facebook Connect, Twitter, OpenID, and potentially other social networks. Users will be able to login using any number of these methods at the same time. My application uses MySQL as a backend database.

有人可以指导我同时从各种社交网络捕获用户信息时我的数据库架构应该是什么样的吗?我有一个想法(基于我的在线阅读)是这样的:

Can someone give me guidance on what my db schema should look like for capturing user info from various social networks at the same time? One idea I have (based on my reading online) is something like:

用户 {userid, ...}
UserFacebook {fbid, userid, ...}
UserTwitter (twid, userid, ...}
等等等等

User {userid, ...}
UserFacebook {fbid, userid, ...}
UserTwitter (twid, userid, ...}
etc., etc.

然后为了获得一个用户的完整图片,我将加入所有用户表.这是其他网站的做法还是有更聪明/更好的方法?

Then to get a complete picture of a user I would join across all the user tables. Is that how other sites do it or is there a smarter/better way?

推荐答案

我建议您将 User 架构放在两个表中:Users 和 Identities.身份应该有:Id、User Id、Adapter、Hash.

I suggest you have your User schema in two tables: Users and Identities. Identities should have: Id, User Id, Adapter, Hash.

对于用户名/密码认证适配器,Hash 将是散列(例如 MD5/SHA1)密码,而其他适配器(Facebook、Twitter 等)将是 Auth Provider 提供的令牌.

For username/password authentication adapter, the Hash will be a hashed (MD5/SHA1 for example) password, while other adapters (Facebook, Twitter, etc) will be the token provided by Auth Provider.

祝你好运.

这篇关于用于多重身份验证、Facebook Connect、Twitter、OpenID 等的数据库架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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