Is it possible to use asp.net identity with an existing collection of usernames and passwords?

StackOverflow https://stackoverflow.com/questions/23473361

سؤال

I currently have a site that is using a handrolled authentication system of usernames and passwords - I do not have the ability to change the current database tables which store the usernames and passwords (the system has been in place for a long time).

Is it possible to use the new asp.net Identity system with existing data? Mapping the columns somehow? I have not seen anything like that in the documentation.

هل كانت مفيدة؟

المحلول

Mapping to the table is the easy part. Its the password encryption/decryption that will be difficult.

You might have to do a permissions migration over to claims or roles.

You simply create a user class with all the fields that match your current db table, and you'll have to add the new ones required by identity 2.0.

var mgr = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>());

public class ApplicationUser : IdentityUser
{
      public string allMyNewFields {get; set;}
}

you will have to implement IPasswordHasher to get the passwords stuff.

Microsoft.AspNet.Identity.PasswordHasher : IPasswordHasher

checkout Asp.net Identity password hashing

good luck

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top