Files
2026-10-29 11:34:35 +08:00

41 lines
922 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Security.Claims;
namespace MAX.Framework.Security;
/// <summary>
/// 令牌生成结果
/// </summary>
public class TokenResult
{
/// <summary>
/// 令牌类型(Bearer)
/// </summary>
public string TokenType { get; set; } = "Bearer";
/// <summary>
/// 访问令牌
/// </summary>
public string Token { get; set; } = string.Empty;
/// <summary>
/// 有效时间(分钟)
/// </summary>
public uint ExpiresInMinutes { get; set; }
}
/// <summary>
/// 数据库令牌服务:生成与校验访问令牌。
/// </summary>
public interface ITokenService
{
/// <summary>
/// 根据声明集合生成访问令牌
/// </summary>
TokenResult CreateToken(IEnumerable<Claim> claims, string? loginIp = null, string? deviceId = null, string? deviceName = null);
/// <summary>
/// 校验令牌,校验失败返回 null
/// </summary>
Task<ClaimsPrincipal?> ValidateTokenAsync(string token);
}