In ASP .NET Webforms, the MachineKey (a guid) was an important part of database security as well as application security. It was used as an encryption key for passwords for forms authentication, so that if the machine key was changed, existing passwords would no longer be recognised. This did provide some level of safety around linking the password store in the db to a token on the webserver. If there were multiple webservers using a single database authentication store, it was necessary for them all to have the same machine ID.
In .NET Core MVC we now have several services we declare in Startup.cs
:
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme,
options => {
options.ExpireTimeSpan = new TimeSpan(0, 45, 0);
options.LoginPath = new PathString("/Account/Login");
options.AccessDeniedPath = new PathString("/Account/AccessDenied");
}
);
services.AddDataProtection()
.SetApplicationName("MyApplicationName")
.PersistKeysToFileSystem(new System.IO.DirectoryInfo(@"C:\server_config\my-app-keys"));
I've had a look at the methods for each service, and none jumps out as providing a data store encryption key. I thought perhaps the ApplicationName might be used as a key, but if I change it, I can still log in with the old passwords, so it's clearly not being used to encrypt.
This article stipulates isolation as one of the key requirements of the API: https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/introduction?view=aspnetcore-3.0
and this one has a simple example using a 'Purpose String' to provide encryption isolation between different logical stores: https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/using-data-protection?view=aspnetcore-3.0
however I can't seem to put this together to tie the password encryption in .NET Core to a specific key.
What am I missing in regard to setting a specific unique encryption key for the standard Asp Net Identity injection, to be used for passwords stored in the database?