0
votes

I have a ASP.NET Web Application (.NET Framework/Angular) and a ASP.NET Core Web Application (Angular). They should run side-by-side. I would like to use the same Identity Database. But it seems that there are different password hasher used. Can I change ASP.NET Core Web Application (Angular) to use the same as ASP.NET Web Application (.NET Framework/Angular) password hasher?

I already updated the database as follow:

ALTER TABLE AspNetUsers ADD
   ConcurrencyStamp VARCHAR(255) NULL,
   LockoutEnd DATETIME NULL,
  NormalizedEmail VARCHAR(255) NULL,
  NormalizedUserName VARCHAR(255) NULL;
GO

ALTER TABLE ASPNETROLES ADD
   ConcurrencyStamp VARCHAR(255) NULL,
   NormalizedName VARCHAR(255) NULL;
GO

CREATE TABLE [dbo].[__EFMigrationsHistory](
    [MigrationId] [nvarchar](150) NOT NULL,
    [ProductVersion] [nvarchar](32) NOT NULL,
 CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY CLUSTERED (MigrationId] ASC) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]
GO

INSERT INTO [dbo].[__EFMigrationsHistory] ([MigrationId] ,[ProductVersion]) VALUES ('00000000000000_CreateIdentitySchema','3.0.0')
GO

See also: https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity-api-authorization

2

2 Answers

0
votes

There is a section in documentation about storing security keys.

public void ConfigureServices(IServiceCollection services)
{
    services.AddDataProtection()
        .PersistKeysToFileSystem(new DirectoryInfo(@"c:\temp-keys\"));
}

Create a key or let the applicaiton create the key, and share it between the 2 applications using this setup.

0
votes

I found the following to get the desired functionality:

Add the following to Startup.cs (.NET Core projects):

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

Migrate the database and update the data:

UPDATE dbo.AspNetUsers SET NormalizedUserName = UPPER(UserName);

For more details see here: https://github.com/iwhp/AspNetIdentitySideBySide