Linked Questions

Popular Questions

Should I avoid using the built in ASP.NET identity mechanism?

Asked by At

I am trying to create an application that has the ability to create user accounts that have a wide range of permissions. I am currently using the built in ASP.NET Core identity system, but I run into some problems that I haven't find any or haven't find any clean solutions and that will get explained later on the post. This had made me thinking of creating my own custom identity mechanism that will fit my needs.

The problems that I am facing are:

  • I am using MySQL as my db provider and upon creating the db tables I was thrown the following exception "Specified key was too long: max key length is 3072 bytes". I managed to fix this issue by overriding the OnModelCreating method and manually changing the HasMaxLength value using the following code

    modelBuilder.Entity<IdentityUserLogin>().Property(ul => ul.LoginProvider).HasMaxLength(36);

    It's not beautiful but it gets the job done.

  • I want my users to be able to add multiple emails and multiple phone numbers to their accounts. The built in ASP.NET Core identity creates an email and a phone number column in the users table. I know I can prevent it from creating those columns but I really don't believe that's the right solution. Basically what I need is to have a table related to the users table that will store the users' emails and one for the phone numbers following the same pattern.
  • My application will have the ability to create dynamic fields and will also have the ability to give its users permissions related to those fields (ex. CanSee,CanEdit,CanDelete). The built in Role authorization system doesn't fit my requirements and I have seen a lot of buzz surrounding the built in Claims authorization system. I have actually read that the implementation of an authorization system that is pretty close to what I need is very complicated and very hard to maintain!

My question is, should I use the built in ASP.Net core identity system to achieve my goals even though I am facing the such problems? Are there any solutions to my problems that I don't know about and would make my life easier while using the ASP.Net core identity system? Should I create my own identity system and if so, how difficult and potentially dangerous such a system will be?

Related Questions