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

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

问题描述

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



有人可以给我指导我的数据库模式应该如何在同一时间从各种社交网络中捕获用户信息?我有一个想法(根据我在线阅读)是这样的:



用户{userid,...}

用户Facebook {fbid,userid ,...}

UserTwitter(twid,userid,...}

等等。



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

解决方案

我建议您将用户模式分为两个表:用户和身份
身份应具有:Id,用户ID,适配器,哈希。



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



祝你好运。


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:

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?

解决方案

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

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.

Good luck.

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

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