Browse Source

Update IdentityServer_To_OpenIddict.md

pull/13403/head
maliming 4 years ago
parent
commit
e685d2a80c
No known key found for this signature in database GPG Key ID: 96224957E51C89E
  1. 26
      docs/en/Migration-Guides/IdentityServer_To_OpenIddict.md

26
docs/en/Migration-Guides/IdentityServer_To_OpenIddict.md

@ -1,10 +1,10 @@
# Migration Identity Server to OpenIddict Guides # Migration Identity Server to OpenIddict Guides
1. Replace all `Volo.Abp.IdentityServer.*` packages with corresponding `Volo.Abp.OpenIddict.*` packages. eg `Volo.Abp.IdentityServer.Domain` to `Volo.Abp.OpenIddict.Domain`. * Replace all `Volo's` `IdentityServer.*` packages with corresponding `OpenIddict.*` packages. eg `Volo.Abp.IdentityServer.Domain` to `Volo.Abp.OpenIddict.Domain`, `Volo.Abp.Account.Web.IdentityServer` to `Volo.Abp.Account.Web.OpenIddict`.
2. Replace all `IdentityServer` modules with corresponding `OpenIddict` modules. eg `AbpIdentityServerDomainModule` to `AbpOpenIddictDomainModule`. * Replace all `IdentityServer` modules with corresponding `OpenIddict` modules. eg `AbpIdentityServerDomainModule` to `AbpOpenIddictDomainModule`, `AbpAccountWebIdentityServerModule` to `AbpAccountWebOpenIddictModule`.
3. Rename the `ConfigureIdentityServer` to `ConfigureOpenIddict` in your `ProjectNameDbContext` class. * Rename the `ConfigureIdentityServer` to `ConfigureOpenIddict` in your `ProjectNameDbContext` class.
4. Remove the `UseIdentityServer` and add `UseAbpOpenIddictValidation` after `UseAuthentication`. * Remove the `UseIdentityServer` and add `UseAbpOpenIddictValidation` after `UseAuthentication`.
5. Add follow code to your startup module. * Add follow code to your startup module.
```cs ```cs
public override void PreConfigureServices(ServiceConfigurationContext context) public override void PreConfigureServices(ServiceConfigurationContext context)
{ {
@ -19,19 +19,23 @@ public override void PreConfigureServices(ServiceConfigurationContext context)
}); });
} }
``` ```
6. If your project is not separate AuthServer please also add `ForwardIdentityAuthenticationForBearer` * If your project is not separate AuthServer please also add `ForwardIdentityAuthenticationForBearer`
```cs ```cs
private void ConfigureAuthentication(ServiceConfigurationContext context) private void ConfigureAuthentication(ServiceConfigurationContext context)
{ {
context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme); context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme);
} }
``` ```
7. Try compiling the project in the IDE and following the errors to remove and reference the code and namespaces. * Update all `Volo.Abp.*` packages to 6.x.
8. Create a new version of the project, then copy `MyProjectName.Domain\OpenIddict\OpenIddictDataSeedContributor.cs` into your project, and update your `\appsettings.json` base on `MyProjectName.DbMigrator\appsettings.json` * Remove the `IdentityServerDataSeedContributor` from the `Domain` project.
9. Add migrations and update the database if you are using EF Core as the database provider. * Create a new version of the project, then copy `MyProjectName.Domain\OpenIddict\OpenIddictDataSeedContributor.cs` into your project, and update your `\appsettings.json` base on `MyProjectName.DbMigrator\appsettings.json`, Be careful to change the port number.
* Copy the `Index.cshtml.cs` and `Index.cs` of new project to your project if you're using `IClientRepository` in `IndexModel`.
If in doubt with the above steps, create a new project to compare the code, or refer to the test project in the module * Update the scope name from `role` to `roles` in `AddAbpOpenIdConnect` method.
* Remove `options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);` from `HttpApi.Host` project.
* 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.
There is a sample that [migrate Identity Server to OpenIddct](https://github.com/abpframework/abp-samples/commit/c6b28246021935566ab2b58e539a1b9602ee5341) for tiered and separate auth server project.
[OpenIddict module document](https://docs.abp.io/en/abp/6.0/Modules/OpenIddict) [OpenIddict module document](https://docs.abp.io/en/abp/6.0/Modules/OpenIddict)

Loading…
Cancel
Save