项目

OpenIddict 4.x 到 5.x 迁移指南

OpenIddict 的 5.0 版本是一次重大更新,包含了破坏性更改。

关于 OpenIddict 5.0 引入的新功能,请查看此博客文章:OpenIddict 5.0 正式发布

我将展示你需要进行迁移所需做出的更改。

在执行迁移前,请备份你的数据库。

OpenIddictApplication 的更改

  1. OpenIddictApplication 实体的 Type(string) 属性已重命名为 ClientType(string)
  2. OpenIddictApplication 实体中新增了 ApplicationType(string) 属性。
  3. OpenIddictApplication 实体中新增了 JsonWebKeySet(string) 属性。
  4. 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 的更改

  1. OpenIddictApplicationModel 实体的 Type(string) 属性已重命名为 ClientType(string)
  2. OpenIddictApplicationModel 实体中新增了 ApplicationType(string) 属性。
  3. OpenIddictApplicationModel 实体中新增了 JsonWebKeySet (JsonWebKeySet) 属性。
  4. OpenIddictApplicationModel 实体中新增了 Settings(string) 属性。

OpenIddictApplicationDescriptor 的更改

在创建新的 AbpApplicationDescriptorOpenIddictApplicationDescriptor 时,你需要将 Type 更改为 ClientType

var application = new AbpApplicationDescriptor {
    ClientId = name,
-   Type = type,
+   ClientType = type,
    ClientSecret = secret,
    ConsentType = consentType,
    DisplayName = displayName,

OpenIddict Pro 模块 UI 的更改

你可以在创建/编辑 OpenIddict 应用程序时更改 ApplicationType,还可以为每个应用程序设置令牌的生命周期。

ropeniddict-pro-application-modal openiddict-pro-application-timelife-modal

在本文档中