简体   繁体   English

在 ASP .NET Core 3.1 中发出验证用户密码的问题

[英]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.我有一个使用 .NET Framework 4.7.1 和 ASP .NET Identity 构建的应用程序来验证我们的用户,我正在使用 IdentityServer4 和 .NET CORE 3.1 和 Identity Core 重写这个应用程序的身份验证部分,我遇到了一个问题:在我在新应用程序中登录,旧应用程序停止验证我在新应用程序中使用的用户。 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:找到之后,我在 Startup.ConfigureServices(IServiceCollection services) 方法的开头添加了如下几行代码:

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.此代码启用了与旧版本 .NET Identity 的兼容模式,这解决了问题,用户的密码得到了很好的验证,并且不再对数据库进行任何更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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