A
As a simpler answer that gives less work, the best would be to generate another solution with Individual User Accounts and transfer the sources of the old solution to the new solution, but it is worth adding the explanation to the case of a fully customized authentication solution.Security is an aspect that can be obtained through the manual implementation of your own authentication scheme. Like ASP.NET Identity is extensible, tailoring becomes very simple, although the set of elements is not). Although very laborious, the re-employment of classes can be very advantageous for anyone who wants to have full control over every aspect that involves authentication and information related to it. Just watch for the goal of each component, which I will explain below. Class SignInManagerThis is the class that performs authentication in fact. When generating a project Individual User Accounts, for example, a Controller (AccountsController.cs) making use of SignInManager. Until the date of this reply, SignInManager is not documented in the MSDN. What exists https://github.com/aspnet/Identity/wiki/Using-Identity-in-ASP.NET-applications and http://www.symbolsource.org/MyGet/Metadata/aspnetwebstacknightly/Project/Microsoft.AspNet.Identity.Owin/2.2.0-alpha1-140723/Release/Default/Microsoft.AspNet.Identity.Owin/Microsoft.AspNet.Identity.Owin/SignInManager.cs?ImageName=Microsoft.AspNet.Identity.Owin . Even examples are not specific for a suitable tailoring. In the same project generated, we also have the following class derived from SignInManager:public class ApplicationSignInManager : SignInManager<ApplicationUser, string>
{
public ApplicationSignInManager(ApplicationUserManager userManager, IAuthenticationManager authenticationManager)
: base(userManager, authenticationManager)
{
}
public override Task<ClaimsIdentity> CreateUserIdentityAsync(ApplicationUser user)
{
return user.GenerateUserIdentityAsync((ApplicationUserManager)UserManager);
}
public static ApplicationSignInManager Create(IdentityFactoryOptions<ApplicationSignInManager> options, IOwinContext context)
{
return new ApplicationSignInManager(context.GetUserManager<ApplicationUserManager>(), context.Authentication);
}
}
Here: public class ApplicationSignInManager : SignInManager<ApplicationUser, string>
Clearly specify that SignInManager will use as user class ApplicationUser, and Id (identifier) of a user will string. You could very well index user using whole numbers, for example. Just change the past type string For int. Already ApplicationUser is derived from IdentityUser. For the case Individual User Accounts, which is a project that uses Entity Framework, use IdentityUser It's okay. If your project uses another technology for database abstraction, ApplicationUser could not derive IdentityUser. Class https://msdn.microsoft.com/en-us/library/microsoft.aspnet.identity.entityframework.identityuser%28v=vs.108%29.aspx IdentityUser implements various concepts that can make your authentication very comprehensive. The standard prototype of the class without specification of the generic classes is:public class IdentityUser : IdentityUser<string, IdentityUserLogin, IdentityUserRole, IdentityUserClaim>, IUser, IUser<string>
string is the representation of the user key. As in ApplicationSignInManager, we are considering that a user's identifier is a string;IdentityUserLogin has the login data and the data of a login provider. Suppose your application will authenticate using a Google login. This class allows this to be done;IdentityUserRole is a class that can associate a user with a Role (the best translation for role role role role rolex is "profil"). This exists to preserve the old profile permission scheme that existed in the previous architecture, known as ASP.NET Membership;IdentityUserClaim associates a user to a claim. In Portuguese, claim it would be something like a "credential", but it's more granular than that. One claim is any information that is part of the identification of a user in the application. For example, your CPF may be a claim. Your RG too. And how is a user created? The answer is in the next class. Class https://msdn.microsoft.com/en-us/library/dn613290%28v=vs.108%29.aspx UserManager is a class whose methods create, alter or delete any user or information related to it, such as roles and claims. For a true customised scheme within the ASP.NET Identity, you need to reimplement this class. As a curiosity, https://www.symbolsource.org/MyGet/Metadata/aspnetwebstacknightly/Project/Microsoft.AspNet.Identity.Core/2.0.0-rtm-140226/Release/Default/Microsoft.AspNet.Identity.Core/Microsoft.AspNet.Identity.Core/UserManager.cs?ImageName=Microsoft.AspNet.Identity.Core . Other Authentication SchemesASP.NET Identity can be tremendously complex for those who are starting to write their own authentication layer. In this context, it is worth returning a little back and mastering the https://msdn.microsoft.com/en-us/library/vstudio/yh26yfzy(v=vs.100).aspx , more limited, but simpler. Here on the site I have already given several answers about it that can be useful: https://pt.stackoverflow.com/questions/27738/tela-de-login-com-membership-e-mvc5/28387?s=1|2.8649#28387 https://pt.stackoverflow.com/questions/25567/seguran%C3%A7a-e-autoriza%C3%A7%C3%A3o-usando-roles/25586#25586 https://pt.stackoverflow.com/questions/21608/pagina-de-login-e-senha/21609#21609