问题
I love StackExhchange / StackOverflow's approach to integrating OpenID.
As I understand it, the process goes something like this:
- If a user signs up with an OpenID provider (i.e. Google), StackOverflow (or similar site) creates an account for the user and associates the OpenID with that account.
- An existing user can associate multiple OpenID accounts with his/her StackExchange account.
I would love to emulate this behavior because I haven't seen it nearly as user-friendly on other sites.
I know StackExchange is built on ASP.NET MVC, but am not sure whether it uses the standard ASP.NET credentialing model and then adds the OpenID provider in a separate DB table or what.
So, my questions are:
- How does StackExchange create these accounts? Do they Create a user in the standard ASP.NET MVC provider and then associate the ID, or is there a separate process?
- how does StackExchange allow additional OpenID provider accounts to be associated with an existing account?
Thanks in advance for any help you can give!
回答1:
The StackExchange sites use the DotNetOpenAuth library (previously known as DotNetOpenId library).
You basically need a User
table and a User_OpenID
table with a one-to-many relationship. Scot Hanselman has a good basic article or try a more in depth overview
来源:https://stackoverflow.com/questions/4395190/how-do-stackexchange-sites-associate-user-accounts-and-openid-logins