OpenIddict 4.x 到 5.x 迁移指南
OpenIddict 的 5.0 版本是一次重大更新,包含了破坏性更改。
关于 OpenIddict 5.0 引入的新功能,请查看此博客文章:OpenIddict 5.0 正式发布。
我将展示你需要进行迁移所需做出的更改。
在执行迁移前,请备份你的数据库。
OpenIddictApplication 的更改
OpenIddictApplication实体的Type(string)属性已重命名为ClientType(string)。- 在
OpenIddictApplication实体中新增了ApplicationType(string)属性。 - 在
OpenIddictApplication实体中新增了JsonWebKeySet(string)属性。 - 在
OpenIddictApplication实体中新增了Settings(string)属性。
新的迁移代码如下所示:
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace OpenIddict.Demo.Server.Migrations
{
/// <inheritdoc />
public partial class openiddict5 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Type",
table: "OpenIddictApplications",
newName: "ClientType");
migrationBuilder.AddColumn<string>(
name: "ApplicationType",
table: "OpenIddictApplications",
type: "nvarchar(50)",
maxLength: 50,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "JsonWebKeySet",
table: "OpenIddictApplications",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Settings",
table: "OpenIddictApplications",
type: "nvarchar(max)",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ApplicationType",
table: "OpenIddictApplications");
migrationBuilder.DropColumn(
name: "JsonWebKeySet",
table: "OpenIddictApplications");
migrationBuilder.DropColumn(
name: "Settings",
table: "OpenIddictApplications");
migrationBuilder.RenameColumn(
name: "ClientType",
table: "OpenIddictApplications",
newName: "Type");
}
}
}
OpenIddictApplicationModel 的更改
OpenIddictApplicationModel实体的Type(string)属性已重命名为ClientType(string)。- 在
OpenIddictApplicationModel实体中新增了ApplicationType(string)属性。 - 在
OpenIddictApplicationModel实体中新增了JsonWebKeySet(JsonWebKeySet) 属性。 - 在
OpenIddictApplicationModel实体中新增了Settings(string)属性。
OpenIddictApplicationDescriptor 的更改
在创建新的 AbpApplicationDescriptor 或 OpenIddictApplicationDescriptor 时,你需要将 Type 更改为 ClientType。
var application = new AbpApplicationDescriptor {
ClientId = name,
- Type = type,
+ ClientType = type,
ClientSecret = secret,
ConsentType = consentType,
DisplayName = displayName,
OpenIddict Pro 模块 UI 的更改
你可以在创建/编辑 OpenIddict 应用程序时更改 ApplicationType,还可以为每个应用程序设置令牌的生命周期。
抠丁客




