- Added ApiClientModel and ApiTokenModel for managing API clients and tokens. - Introduced ConfigurationDefinitionModel and ConfigurationValueModel for configuration management. - Created CredentialSecretModel for storing credential secrets. - Developed DeploymentArtifactModel and DeploymentBatchModel for deployment management. - Enhanced DeploymentTargetModel and DeploymentTemplateSelectionModel to support template revisions. - Added TemplateRevisionModel and TemplateVersionModel for versioning templates. - Implemented ApiClientSecretHasher for secure secret hashing. - Created ApiTokenService for generating and validating JWT tokens. - Updated QueueJobService to handle deployment requests with artifacts. - Configured authentication settings in appsettings.json for JWT and Negotiate authentication.
72 lines
3.3 KiB
C#
72 lines
3.3 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Microsoft.SelfService.Portal.Core.API.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddApiTokenManagement : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "ApiTokens",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWID()"),
|
|
Jti = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
|
|
Subject = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
SubjectType = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: false),
|
|
ApiClientId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
ScopesJson = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
IssuedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
ExpiresAt = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
RevokedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
RevokedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
LastUsedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
Modified = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()"),
|
|
ModifiedBy = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Created = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()"),
|
|
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ApiTokens", x => x.Id);
|
|
table.CheckConstraint("CK_ApiTokens_ScopesJson_IsJson", "ISJSON([ScopesJson]) = 1");
|
|
table.ForeignKey(
|
|
name: "FK_ApiTokens_ApiClients_ApiClientId",
|
|
column: x => x.ApiClientId,
|
|
principalTable: "ApiClients",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ApiTokens_ApiClientId",
|
|
table: "ApiTokens",
|
|
column: "ApiClientId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ApiTokens_Jti",
|
|
table: "ApiTokens",
|
|
column: "Jti",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ApiTokens_SubjectType_Subject",
|
|
table: "ApiTokens",
|
|
columns: new[] { "SubjectType", "Subject" });
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "ApiTokens");
|
|
}
|
|
}
|
|
}
|