Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Asp.net mvc 5 authentication without using Microsoft.AspNet.Identity.EntityFramework

How do you create a custom ASP.NET MVC 5 Auth without using the UserStore of Microsoft.AspNet.Identity.EntityFramework??

like image 977
John Patrick Po Avatar asked Aug 25 '14 14:08

John Patrick Po


People also ask

What is Microsoft ASP.NET identity?

ASP.NET Core Identity: Is an API that supports user interface (UI) login functionality. Manages users, passwords, profile data, roles, claims, tokens, email confirmation, and more.

How do I change the authentication in MVC project?

Select File >> New >> select ASP.NET Core Web Application, and change the authentication to Windows Authentication. We can also configure the existing application for Windows Authentication by selecting the option of WA. To configure the authentication manually, open Visual Studio project properties >> go to Debug tab.


1 Answers

All you have to do is implement the same interfaces that the Userstore for Identity.Entityframework uses.

User will be your user class

public class MyUserStore<TUser> : 
    IUserLoginStore<TUser, int>, 
    IUserClaimStore<TUser, int>, 
    IUserRoleStore<TUser, int>, 
    IUserPasswordStore<TUser, int>, 
    IUserSecurityStampStore<TUser, int>, 
    IUserStore<TUser, int>, 
    IDisposable where TUser : User
{
   //Implement the interfaces you need
}

Then pass your MyUserStore into the UserManager each request

new UserManager<User, int>(new MyUserStore<User>(new MyContext()))
like image 74
James Sampica Avatar answered Oct 06 '22 00:10

James Sampica