Database Schema for multiple authentications, Facebook Connect, Twitter, OpenID, etc

 ̄綄美尐妖づ 提交于 2019-11-29 23:35:15

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.

This is what i do, i separate the accounts table from the authentication process, e.g. the account holds the account name, registration date, and unique id maybe. Then I can create 4 additional tables for example: users_openid, users_facebook, users_twitter and users (for your normal username/website authentication), all have a foreign key (account_id) that links to the account table.

This way you separate how the user sign-in to your system and the actual account.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!