将密码哈希从ASP.NET Identity 2.0迁移到3.0

Chr*_*arz 5 asp.net asp.net-identity asp.net-core

目前,我使用ASP.NET Identity 2.0生成密码哈希.

是否可以使用新的ASP.NET Identity 3.0验证这些密码?

ade*_*lin 5

尝试设置PasswordHasherCompatibilityMode为 V2(以下代码未测试):

    public void ConfigureServices(IServiceCollection services)
    {
        services.Configure<PasswordHasherOptions>(options => options.CompatibilityMode = PasswordHasherCompatibilityMode.IdentityV2);
    }
Run Code Online (Sandbox Code Playgroud)

另请参阅如何在 ASP.NET 5 Identity 中设置 PasswordHasherCompatibilityMode.IdentityV3?

  • 没关系,我的旧帐户在表中有空的“NormalizedUserName”字段。现在它可以正常工作。谢谢 (3认同)
  • 请注意,`PasswordHasherCompatibilityMode.IdentityV2` 将**也使用旧的(和不安全的)格式存储密码**!Identity 3 **already** 的默认密码哈希器支持验证旧的 IdentityV2 格式的密码,无需更改兼容模式。您应该保持兼容模式为 V3。将兼容模式修改为 V2 的唯一理由是针对同时使用**新旧身份系统的应用程序。 (2认同)