Migration Identity Server to OpenIddict Guide
This document explains how to migrate an application from IdentityServer4 to OpenIddict. ABP startup templates have used OpenIddict as the authentication server by default since v6.0.0.
The checklist below describes the v6.0 transition. For a layer-by-layer migration, use the IdentityServer to OpenIddict step-by-step guide and apply the package version that matches the ABP version of your application.
History
IdentityServer4 is archived and no longer maintained by its owners. ABP did not migrate its integration to the commercial Duende IdentityServer product. The ABP IdentityServer integration packages are still shipped for existing applications, while new applications use OpenIddict. See the Duende IdentityServer announcement for the background.
OpenIddict Migration Steps
- Update all
Volo'spackages to6.x. - Replace all
Volo'sIdentityServer.*packages with correspondingOpenIddict.*packages. egVolo.Abp.IdentityServer.DomaintoVolo.Abp.OpenIddict.Domain,Volo.Abp.Account.Web.IdentityServertoVolo.Abp.Account.Web.OpenIddict. - Replace all
IdentityServermodules with correspondingOpenIddictmodules. egAbpIdentityServerDomainModuletoAbpOpenIddictDomainModule,AbpAccountWebIdentityServerModuletoAbpAccountWebOpenIddictModule. - Rename the
ConfigureIdentityServertoConfigureOpenIddictin yourProjectNameDbContextclass. - Remove the
UseIdentityServerand addUseAbpOpenIddictValidationafterUseAuthentication. - Add the following code to your startup module.
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<OpenIddictBuilder>(builder =>
{
builder.AddValidation(options =>
{
options.AddAudiences("ProjectName"); // Change ProjectName to your project name.
options.UseLocalServer();
options.UseAspNetCore();
});
});
}
- If your project does not have a separate AuthServer, also add
ForwardIdentityAuthenticationForBearer.
private void ConfigureAuthentication(ServiceConfigurationContext context)
{
context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme);
}
- Remove the
IdentityServerDataSeedContributorfrom theDomainproject. - Generate a temporary project with the same name and architecture as the existing project so you can compare the current OpenIddict setup.
- Copy the generated
ProjectName.Domain\OpenIddict\OpenIddictDataSeedContributor.csinto your project and updateappsettings.jsonbased onProjectName.DbMigrator\appsettings.json. Adjust the ports and client URLs for your application. - Copy the generated
Index.cshtml.csandIndex.cshtmlfiles into your project if yourIndexModelstill usesIClientRepository. - Update the scope name from
roletorolesinAddAbpOpenIdConnectmethod. - Remove
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);fromHttpApi.Hostproject. - AuthServer no longer requires
JWT bearer authentication. Please remove it. egAddJwtBearerandUseJwtTokenMiddleware. - Try compiling the project in the IDE and following the errors to remove and reference the code and namespaces.
- Add migrations and update the database if you are using EF Core as the database provider.
Module packages
Open source side
- Volo.Abp.OpenIddict.Domain (
AbpOpenIddictDomainModule) - Volo.Abp.OpenIddict.Domain.Shared (
AbpOpenIddictDomainSharedModule) - Volo.Abp.OpenIddict.EntityFrameworkCore (
AbpOpenIddictEntityFrameworkCoreModule) - Volo.Abp.OpenIddict.AspNetCore (
AbpOpenIddictAspNetCoreModule) - Volo.Abp.OpenIddict.MongoDB (
AbpOpenIddictMongoDbModule) - Volo.Abp.Account.Web.OpenIddict (
AbpAccountWebOpenIddictModule) - Volo.Abp.PermissionManagement.Domain.OpenIddict (
AbpPermissionManagementDomainOpenIddictModule)
Commercial side
- Volo.Abp.OpenIddict.Pro.Application.Contracts (
AbpOpenIddictProApplicationContractsModule) - Volo.Abp.OpenIddict.Pro.Application (
AbpOpenIddictProApplicationModule) - Volo.Abp.OpenIddict.Pro.HttpApi.Client (
AbpOpenIddictProHttpApiClientModule) - Volo.Abp.OpenIddict.Pro.HttpApi (
AbpOpenIddictProHttpApiModule) - Volo.Abp.OpenIddict.Pro.Blazor(
AbpOpenIddictProBlazorModule) - Volo.Abp.OpenIddict.Pro.Blazor.Server (
AbpOpenIddictProBlazorServerModule) - Volo.Abp.OpenIddict.Pro.Blazor.WebAssembly (
AbpOpenIddictProBlazorWebAssemblyModule) - Volo.Abp.OpenIddict.Pro.Web (
AbpOpenIddictProWebModule)