Search code examples
asp.net-mvc-5asp.net-identityowin

Customizing ASP.NET Identity, OWIN and Social provider logins


I am new to ASP.NET MVC 5 and OWIN.

I have upgraded my project to MVC 5 to implement the authentication and authorization of my project. Problem is that my project does not store the user data. When user logins in I ask a different system via a WCF service to tell me if the user is authenticated. So I do not have a database nor tables that the user is stored in.

But I want to add the ability to login via social providers using OWIN. For this I will add a local database table to store the social provider Id/Token

Looking around other have asked similar question but only when they want to change database type store... Whilst I actually don't store the data... Is it still possible to customize this with ASP.NET Identity and how would I do this?


Solution

  • I looked into the solutions suggested. I found that the method names of the interfaces to implement did not really fit and there where way too many methods as well.

    I ended up only using the OWIN Context in AccountController to extract the LoginInfo with all the details I wanted. This way I did not have to implement any custom versions of IUserLoginStore etc...

    I wanted the simplest solution to implement and therefore I ended up with: 1. Added StartupAuth class from template mvc project and configured different providers there 1. In AccountController: Extracted the claims from LoginInfo, 2. Stored OpenId in a table for lookup and then continued on as before.