Migrating from IdentityServer to OpenIddict Step by Step Guide
This guide provides layer-by-layer guidance for migrating your existing application to OpenIddict. Since OpenIddict is only available with VCP v6.0, you will need to update your existing application in order to apply OpenIddict changes.
History
We are not removing the Identity Server packages and we will continue to release new versions of IdentityServer-related NuGet/NPM packages. That means you won't have an issue while upgrading to v6.0 when the stable version is released. We will continue to fix bugs in our packages for a while. VCP 7.0 will be based on .NET 7. If Identity Server continues to work with .NET 7, we will also continue to ship NuGet packages for our IDS integration.
On the other hand, Identity Server ends support for the open-source Identity Server at the end of 2022. The Identity Server team has decided to move to Duende IDS and VCP will not be migrated to the commercial Duende IDS. You can see the Duende Identity Server announcement from this link.
OpenIddict Migration Steps
Use the vcp update
command to update your existing application. See the Upgrading docs for more info. Apply the required migrations by following the Migration Guides based on your application version.
Domain.Shared Layer
In MyApplication.Domain.Shared.csproj replace the project reference:
<PackageReference Include="Verto.Vcp.IdentityServer.Domain.Shared" Version="6.0.*" />
with
<PackageReference Include="Verto.Vcp.OpenIddict.Domain.Shared" Version="6.0.*" />
In MyApplicationDomainSharedModule.cs replace the usings and module dependencies:
using Verto.Vcp.IdentityServer; ... typeof(VcpIdentityServerDomainSharedModule)
with
using Verto.Vcp.OpenIddict; ... typeof(VcpOpenIddictDomainSharedModule)
Domain Layer
In MyApplication.Domain.csproj replace the project references:
<PackageReference Include="Verto.Vcp.IdentityServer.Domain" Version="6.0.*" /> <PackageReference Include="Verto.Vcp.PermissionManagement.Domain.IdentityServer" Version="6.0.*" />
with
<PackageReference Include="Verto.Vcp.OpenIddict.Domain" Version="6.0.*" /> <PackageReference Include="Verto.Vcp.PermissionManagement.Domain.OpenIddict" Version="6.0.*" />
In MyApplicationDomainModule.cs replace the usings and module dependencies:
using Verto.Vcp.IdentityServer; using Verto.Vcp.PermissionManagement.IdentityServer; ... typeof(VcpIdentityServerDomainModule), typeof(VcpPermissionManagementDomainIdentityServerModule),
with
using Verto.Vcp.OpenIddict; using Verto.Vcp.PermissionManagement.OpenIddict; ... typeof(VcpOpenIddictDomainModule), typeof(VcpPermissionManagementDomainOpenIddictModule),
OpenIddictDataSeedContributor
- Create a folder named OpenIddict under the Domain project and copy the OpenIddictDataSeedContributor.cs under this folder. Rename all the
Ids2OpenId
with your project name. - Delete the IdentityServer folder that contains
IdentityServerDataSeedContributor.cs
which is no longer needed.
You can also create a project with the same name and copy the OpenIddict
folder of the new project into your project.
EntityFrameworkCore Layer
If you are using MongoDB, skip this step and check the MongoDB layer section.
In MyApplication.EntityFrameworkCore.csproj replace the project reference:
<PackageReference Include="Verto.Vcp.IdentityServer.EntityFrameworkCore" Version="6.0.*" />
with
<PackageReference Include="Verto.Vcp.OpenIddict.EntityFrameworkCore" Version="6.0.*" />
In MyApplicationEntityFrameworkCoreModule.cs replace the usings and module dependencies:
using Verto.Vcp.IdentityServer.EntityFrameworkCore; ... typeof(VcpIdentityServerEntityFrameworkCoreModule),
with
using Verto.Vcp.OpenIddict.EntityFrameworkCore; ... typeof(VcpOpenIddictEntityFrameworkCoreModule),
In MyApplicationDbContext.cs replace the usings and fluent api configurations:
using Verto.Vcp.IdentityServer.EntityFrameworkCore; ... using Verto.Vcp.OpenIddict.EntityFrameworkCore; ... protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); /* Include modules to your migration db context */ ... builder.ConfigureIdentityServer();
with
using Verto.Vcp.OpenIddict.EntityFrameworkCore; ... protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); /* Include modules to your migration db context */ ... builder.ConfigureOpenIddict();
MongoDB Layer
If you are using EntityFrameworkCore, skip this step and check the EntityFrameworkCore layer section.
In MyApplication.MongoDB.csproj replace the project reference:
<PackageReference Include="Verto.Vcp.IdentityServer.MongoDB" Version="6.0.*" />
with
<PackageReference Include="Verto.Vcp.OpenIddict.MongoDB" Version="6.0.*" />
In MyApplicationMongoDbModule.cs replace the usings and module dependencies:
using Verto.Vcp.IdentityServer.MongoDB; ... typeof(VcpIdentityServerMongoDbModule),
with
using Verto.Vcp.OpenIddict.MongoDB; ... typeof(VcpOpenIddictMongoDbModule),
DbMigrator Project
In MyApplication.DbMigrator.csproj add the project reference:
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
for creating the host builder.
In
appsettings.json
replace the IdentityServer section with OpenIddict:"OpenIddict": { "Applications": { "MyApplication_Web": { "ClientId": "MyApplication_Web", "ClientSecret": "1q2w3e*", "RootUrl": "https://localhost:44384" }, "MyApplication_App": { "ClientId": "MyApplication_App", "RootUrl": "http://localhost:4200" }, "MyApplication_BlazorServerTiered": { "ClientId": "MyApplication_BlazorServerTiered", "ClientSecret": "1q2w3e*", "RootUrl": "https://localhost:44346" }, "MyApplication_Swagger": { "ClientId": "MyApplication_Swagger", "RootUrl": "https://localhost:44391" } } }
Replace MyApplication with your application name.
Application Contracts Layer
In MyApplication.Application.Contracts.csproj replace the project reference:
<PackageReference Include="Verto.Vcp.IdentityServer.Application.Contracts" Version="6.0.*" />
with
<PackageReference Include="Verto.Vcp.OpenIddict.Pro.Application.Contracts" Version="6.0.*" />
In MyApplicationApplicationContractsModule.cs replace the usings and module dependencies:
using Verto.Vcp.IdentityServer; ... typeof(VcpIdentityServerApplicationContractsModule),
with
using Verto.Vcp.OpenIddict; ... typeof(VcpOpenIddictProApplicationContractsModule),
Application Layer
In MyApplication.Application.csproj replace the project reference:
<PackageReference Include="Verto.Vcp.IdentityServer.Application" Version="6.0.*" />
with
<PackageReference Include="Verto.Vcp.OpenIddict.Pro.Application" Version="6.0.*" />
In MyApplicationApplicationModule.cs replace the usings and module dependencies:
using Verto.Vcp.IdentityServer; ... typeof(VcpIdentityServerApplicationModule),
with
using Verto.Vcp.OpenIddict; ... typeof(VcpOpenIddictProApplicationModule),
HttpApi Layer
In MyApplication.HttpApi.csproj replace the project reference:
<PackageReference Include="Verto.Vcp.IdentityServer.HttpApi" Version="6.0.*" />
with
<PackageReference Include="Verto.Vcp.OpenIddict.Pro.HttpApi" Version="6.0.*" />
In MyApplicationHttpApiModule.cs replace the usings and module dependencies:
using Verto.Vcp.IdentityServer; ... typeof(VcpIdentityServerHttpApiModule),
with
using Verto.Vcp.OpenIddict; ... typeof(VcpOpenIddictProHttpApiModule),
HttpApi.Client Layer
In MyApplication.HttpApi.Client.csproj replace the project reference:
<PackageReference Include="Verto.Vcp.IdentityServer.HttpApi.Client" Version="6.0.*" />
with
<PackageReference Include="Verto.Vcp.OpenIddict.Pro.HttpApi.Client" Version="6.0.*" />
In MyApplicationHttpApiModule.cs replace the usings and module dependencies:
using Verto.Vcp.IdentityServer; ... typeof(VcpIdentityServerHttpApiClientModule),
with
using Verto.Vcp.OpenIddict; ... typeof(VcpOpenIddictProHttpApiClientModule),
Test Project
In MyApplicationTestBaseModule.cs remove the IdentityServer related using and PreConfigurations:
using Verto.Vcp.IdentityServer;
and
PreConfigure<VcpIdentityServerBuilderOptions>(options => { options.AddDeveloperSigningCredential = false; }); PreConfigure<IIdentityServerBuilder>(identityServerBuilder => { identityServerBuilder.AddDeveloperSigningCredential(false, System.Guid.NewGuid().ToString()); });
from
PreConfigureServices
.
Migration
Add a new migration that reflects the underlying changes via dotnet ef migrations add VcpOpenIddictMigration
UI Layer
Source code of the samples and module
- Open source tiered & separate auth server application migrate Identity Server to OpenIddct
- Commercial tiered & separate auth server application migrate Identity Server to OpenIddct
- OpenIddict module document
- OpenIddict module source code