简体   繁体   中英

Issue validating user passwords in ASP .NET Core 3.1

I have an application built using .NET Framework 4.7.1 with ASP .NET Identity to authenticate our users and I am rewriting the authentication part of this application using IdentityServer4 with .NET CORE 3.1 with Identity Core and I am having an issue: after I make a login in the new app, the old one stops to validate the user I used in the new app. Steps to reproduce:

  1. Login in the old app: Success
  2. Login in the new app: Success
  3. Login in the old app: Fail, the user password cannot be validated

Does anyone know how to solve this issue?

Thanks

I found out that the new Application was updating the user password hash in the database. After I found it, I added the following lines of code in the beginning of the Startup.ConfigureServices(IServiceCollection services) method:

services.Configure<PasswordHasherOptions>(options => {
    options.CompatibilityMode = PasswordHasherCompatibilityMode.IdentityV2;
});

This code enabled the compatibility mode with older versions of the .NET Identity and this fixed the issue, the user's passwords are being validated fine and no updates are done to the database anymore.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM