I am creating a project that uses EF Code First approach and now I have to create the users. I want to implement OpenID, because it is really cool and modern. There are plenty of tutorials of how to do that (haven’t read them, but I will of course).
I am pretty used now to EF and MVC, but all the stuff with the members, roles, providers, etc is foggy. There are two things that I am certain of:
- I want to use OpenID and
- I want to manage the users table with EF Code First
So I would appreciate if anyone can give me some hints:
- Do I have to implement the MembershipProvider or I could use a project like this one: codeplex?
- How OpenID, EF and Membership will go along with each other?
I know that this is VERY wide subject, but I need only basic hints, I need to know from where to start. Things like “You can use MembershipProvider and OpenID, but you better don’t, because…”.
Any help is greatly appreciated.
What we are looking at is providing multiple Authentication options to our end Users, whether it be a username and password combination that you manage, an OpenId provider or an OAuth provider.
I find the best approach is to make these two concepts (membership and authentication) explicit.
A simple approach to have a User table with the following information:
Example:
When the user authenticates, we can load their user information using the authentication method and id as the criteria. For the internal membership provider we can use their username, for OpenId their claim url and for OAuth their provider id (such as the Twitter id).
So by all means use EF to manage your Users but I would treat the membership provider as just another authentication mechanism in which case you may as well use the standard SqlMembershipProvider.
I wrote this post a long time ago (in the context of eCommerce stores) that may be of some use.