Migrating Microservice Application to OpenIddict Guide
This guide provides guidance for migrating your existing microservice application to OpenIddict. Since OpenIddict is only available with ABP v6.0, you will need to update your existing application in order to apply OpenIddict changes.
History
We are not removing 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 releases. We will continue to fix bugs in our packages for a while. ABP 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 ABP 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 abp update
command to update your existing application. See Upgrading docs for more info. Apply required migrations by following the Migration Guides based on your application version.
AuthServer Application
In MyApplication.AuthServer.csproj replace project reference:
with
In MyApplicationAuthServerModule.cs replace usings and module dependencies:
with
In MyApplicationAuthServerModule.cs update PreConfigureServices method like below:
In MyApplicationAuthServerModule.cs remove JwtBeaer authentication options:
In MyApplicationAuthServerModule.cs
OnApplicationInitialization
method replace IdentityServer and JwtToken midware:with
To use the new AuthServer page, replace Index.cshtml.cs with AuthServer Index.cshtml.cs and Index.cshtml file with AuthServer Index.cshtml.
Note: It can be found under the Pages folder.
AdministrationService Domain Layer
In MyApplication.AdministrationService.Domain.csproj replace project reference:
with
In MyApplicationDomainSharedModule.cs replace usings and module dependencies:
with
IdentityService Domain Shared Layer
In MyApplication.IdentityService.Domain.Shared.csproj replace project references:
with
In MyApplicationDomainModule.cs replace usings and module dependencies:
with
IdentityService Domain Layer
In MyApplication.IdentityService.Application.Contracts.csproj replace project references:
with
In IdentityServiceDomainModule.cs replace usings and module dependencies:
with
IdentityService Application.Contracts Layer
In MyApplication.IdentityService.Application.Contracts.csproj replace project references:
with
In IdentityServiceApplicationContractsModule.cs.cs replace usings and module dependencies:
with
IdentityService Application Layer
In MyApplication.IdentityService.Application.csproj replace project references:
with
In IdentityServiceApplicationModule.cs replace usings and module dependencies:
with
IdentityService EntityFrameworkCore Layer
In MyApplication.IdentityService.EntityFrameworkCore.csproj replace project reference:
with
In IdentityServiceEntityFrameworkCoreModule.cs.cs replace usings and module dependencies:
with
In IdentityServiceEntityFrameworkCoreModule.cs.cs replace
AddAbpDbContext
options:with
In IdentityServiceDbContext.cs replace implemented dbcontexts:
with
Afterwards you should have the DbSets like below:
In IdentityServiceDbContext.cs replace usings and fluent api configurations:
with
Don't forget to create new migration using
donet ef
command
IdentityService HttpApi Layer
In MyApplication.IdentityService.HttpApi.csproj replace project reference:
with
In IdentityServiceHttpApiModule.cs replace usings and module dependencies:
with
IdentityService HttpApi.Client Layer
In MyApplication.IdentityService.HttpApi.Client.csproj replace project reference:
with
In IdentityServiceHttpApiClientModule.cs replace usings and module dependencies:
with
IdentityServer Data Seeder
It is recommended to update the IdentityServerDataSeeder.cs
in the MyApplication.IdentityService.HttpApi.Host project under the DbMigrations folder.
Use the Updated IdentityServerDataSeeder to update your existing IdentityServer data seeder. Replace the Acme.BookStore
namespace to your application namespace.
In appsettings.json
replace IdentityServer section with OpenIddict and Clients to Applications. You should have something like:
If you are using DbMigrator, you should make the same changes in
IdentityServerDataSeeder
and appsettings.json located under DbMigrator project.
Note: Don't forget to have a trailing slash
/
at the end of the root urls.
IdentityService Web Layer
In MyApplication.IdentityService.HttpApi.Client.csproj replace project reference:
with
In IdentityServiceWebModule.cs replace usings and module dependencies:
with
In IdentityServiceWebModule.cs add object mapping configurations:
Shared Hosting Module
In MyApplicationSharedHostingModule replace the database configuration:
with
Public Web Application
In the AddAbpOpenIdConnect configuration options, update options.Scope.Add("role");
to options.Scope.Add("roles");
.
Back-Office Application
Based on your UI choice, you need to update OpenIdConnect options as in the Public-Web application. Update role scope to roles.
To update the menu, navigate to MyApplicationMenuContributor.cs (or NavigationContributor) and replace the menu names:
with