- 新增 WindowsCredential 模型和控制器,用于管理 Windows 凭据 - 新增 RemoteAccessToken 模型,支持生成可分享的远程访问链接 - 更新 RemoteDesktopController,添加 Token 生成、验证、撤销等 API - 更新前端 RemoteDesktopModal,支持4种连接方式:快速连接、生成分享链接、手动输入、链接管理 - 新增 WindowsCredentialManager 组件用于管理 Windows 凭据 - 新增 RemoteAccessPage 用于通过 Token 访问远程桌面 - 添加 Vue Router 支持 /remote/:token 路由 - 更新数据库迁移,添加 WindowsCredentials 和 RemoteAccessTokens 表
111 lines
5.3 KiB
C#
111 lines
5.3 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Metadata;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace AmtScanner.Api.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddWindowsCredentialsAndRemoteAccessTokens : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "WindowsCredentials",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
Name = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Username = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Password = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Domain = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
IsDefault = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
Note = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_WindowsCredentials", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "RemoteAccessTokens",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
Token = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
DeviceId = table.Column<long>(type: "bigint", nullable: false),
|
|
WindowsCredentialId = table.Column<long>(type: "bigint", nullable: true),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
ExpiresAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
IsUsed = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
UsedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
MaxUseCount = table.Column<int>(type: "int", nullable: false),
|
|
UseCount = table.Column<int>(type: "int", nullable: false),
|
|
Note = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: true)
|
|
.Annotation("MySql:CharSet", "utf8mb4")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_RemoteAccessTokens", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_RemoteAccessTokens_AmtDevices_DeviceId",
|
|
column: x => x.DeviceId,
|
|
principalTable: "AmtDevices",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_RemoteAccessTokens_WindowsCredentials_WindowsCredentialId",
|
|
column: x => x.WindowsCredentialId,
|
|
principalTable: "WindowsCredentials",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_RemoteAccessTokens_DeviceId",
|
|
table: "RemoteAccessTokens",
|
|
column: "DeviceId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_RemoteAccessTokens_Token",
|
|
table: "RemoteAccessTokens",
|
|
column: "Token",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_RemoteAccessTokens_WindowsCredentialId",
|
|
table: "RemoteAccessTokens",
|
|
column: "WindowsCredentialId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_WindowsCredentials_Name",
|
|
table: "WindowsCredentials",
|
|
column: "Name");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "RemoteAccessTokens");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "WindowsCredentials");
|
|
}
|
|
}
|
|
}
|