- 新增 WindowsCredential 模型和控制器,用于管理 Windows 凭据 - 新增 RemoteAccessToken 模型,支持生成可分享的远程访问链接 - 更新 RemoteDesktopController,添加 Token 生成、验证、撤销等 API - 更新前端 RemoteDesktopModal,支持4种连接方式:快速连接、生成分享链接、手动输入、链接管理 - 新增 WindowsCredentialManager 组件用于管理 Windows 凭据 - 新增 RemoteAccessPage 用于通过 Token 访问远程桌面 - 添加 Vue Router 支持 /remote/:token 路由 - 更新数据库迁移,添加 WindowsCredentials 和 RemoteAccessTokens 表
86 lines
1.9 KiB
C#
86 lines
1.9 KiB
C#
using System.ComponentModel.DataAnnotations;
|
||
|
||
namespace AmtScanner.Api.Models;
|
||
|
||
/// <summary>
|
||
/// 远程访问临时 Token
|
||
/// </summary>
|
||
public class RemoteAccessToken
|
||
{
|
||
[Key]
|
||
public long Id { get; set; }
|
||
|
||
/// <summary>
|
||
/// 唯一 Token 字符串
|
||
/// </summary>
|
||
[Required]
|
||
[MaxLength(64)]
|
||
public string Token { get; set; } = string.Empty;
|
||
|
||
/// <summary>
|
||
/// 关联的设备 ID
|
||
/// </summary>
|
||
public long DeviceId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 关联的设备
|
||
/// </summary>
|
||
public AmtDevice? Device { get; set; }
|
||
|
||
/// <summary>
|
||
/// 关联的 Windows 凭据 ID
|
||
/// </summary>
|
||
public long? WindowsCredentialId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 关联的 Windows 凭据
|
||
/// </summary>
|
||
public WindowsCredential? WindowsCredential { get; set; }
|
||
|
||
/// <summary>
|
||
/// 创建时间
|
||
/// </summary>
|
||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||
|
||
/// <summary>
|
||
/// 过期时间
|
||
/// </summary>
|
||
public DateTime ExpiresAt { get; set; }
|
||
|
||
/// <summary>
|
||
/// 是否已使用(一次性 Token)
|
||
/// </summary>
|
||
public bool IsUsed { get; set; } = false;
|
||
|
||
/// <summary>
|
||
/// 使用时间
|
||
/// </summary>
|
||
public DateTime? UsedAt { get; set; }
|
||
|
||
/// <summary>
|
||
/// 最大使用次数(0 表示无限制)
|
||
/// </summary>
|
||
public int MaxUseCount { get; set; } = 1;
|
||
|
||
/// <summary>
|
||
/// 已使用次数
|
||
/// </summary>
|
||
public int UseCount { get; set; } = 0;
|
||
|
||
/// <summary>
|
||
/// 创建者备注
|
||
/// </summary>
|
||
[MaxLength(500)]
|
||
public string? Note { get; set; }
|
||
|
||
/// <summary>
|
||
/// 检查 Token 是否有效
|
||
/// </summary>
|
||
public bool IsValid()
|
||
{
|
||
if (DateTime.UtcNow > ExpiresAt) return false;
|
||
if (MaxUseCount > 0 && UseCount >= MaxUseCount) return false;
|
||
return true;
|
||
}
|
||
}
|