Add transfer tracking and secure admin access
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
namespace MiaoJiZhang.Domain.Entities;
|
||||
|
||||
public static class AdminRoles
|
||||
{
|
||||
public const string SuperAdmin = "super_admin";
|
||||
public const string Operator = "operator";
|
||||
public const string Viewer = "viewer";
|
||||
|
||||
public static readonly string[] All = [SuperAdmin, Operator, Viewer];
|
||||
}
|
||||
|
||||
public class AdminUser
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Username { get; set; } = null!;
|
||||
public string PasswordHash { get; set; } = null!;
|
||||
public string Role { get; set; } = AdminRoles.Viewer;
|
||||
public bool IsActive { get; set; } = true;
|
||||
public bool MustChangePassword { get; set; }
|
||||
public int AuthVersion { get; set; }
|
||||
public int FailedLoginCount { get; set; }
|
||||
public DateTime? LockedUntil { get; set; }
|
||||
public DateTime? LastLoginAt { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
public ICollection<AdminSession> Sessions { get; set; } = [];
|
||||
}
|
||||
|
||||
public class AdminSession
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public long AdminUserId { get; set; }
|
||||
public AdminUser AdminUser { get; set; } = null!;
|
||||
public string TokenHash { get; set; } = null!;
|
||||
public string CsrfTokenHash { get; set; } = null!;
|
||||
public int AuthVersion { get; set; }
|
||||
public DateTime ExpiresAt { get; set; }
|
||||
public DateTime AbsoluteExpiresAt { get; set; }
|
||||
public DateTime? RevokedAt { get; set; }
|
||||
public DateTime LastSeenAt { get; set; }
|
||||
public string? IpAddress { get; set; }
|
||||
public string? UserAgent { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
|
||||
public class AdminAuditLog
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public long? AdminUserId { get; set; }
|
||||
public string? Username { get; set; }
|
||||
public string Action { get; set; } = null!;
|
||||
public string Resource { get; set; } = null!;
|
||||
public string HttpMethod { get; set; } = null!;
|
||||
public string Path { get; set; } = null!;
|
||||
public int StatusCode { get; set; }
|
||||
public bool Success { get; set; }
|
||||
public string? Detail { get; set; }
|
||||
public string? IpAddress { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user