Init Git
This commit is contained in:
12
AMREZ.EOP.Domain/Entities/Authentications/Permission.cs
Normal file
12
AMREZ.EOP.Domain/Entities/Authentications/Permission.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using AMREZ.EOP.Domain.Entities.Common;
|
||||
|
||||
namespace AMREZ.EOP.Domain.Entities.Authentications;
|
||||
|
||||
public sealed class Permission : BaseEntity
|
||||
{
|
||||
public Guid TenantId { get; set; }
|
||||
public string Code { get; set; } = default!; // e.g. "auth:session:read"
|
||||
public string Name { get; set; } = default!;
|
||||
|
||||
public ICollection<RolePermission> RolePermissions { get; set; } = new List<RolePermission>();
|
||||
}
|
||||
13
AMREZ.EOP.Domain/Entities/Authentications/Role.cs
Normal file
13
AMREZ.EOP.Domain/Entities/Authentications/Role.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using AMREZ.EOP.Domain.Entities.Common;
|
||||
|
||||
namespace AMREZ.EOP.Domain.Entities.Authentications;
|
||||
|
||||
public sealed class Role : BaseEntity
|
||||
{
|
||||
public Guid TenantId { get; set; }
|
||||
public string Code { get; set; } = default!; // system code, unique per tenant
|
||||
public string Name { get; set; } = default!;
|
||||
|
||||
public ICollection<UserRole> UserRoles { get; set; } = new List<UserRole>();
|
||||
public ICollection<RolePermission> RolePermissions { get; set; } = new List<RolePermission>();
|
||||
}
|
||||
13
AMREZ.EOP.Domain/Entities/Authentications/RolePermission.cs
Normal file
13
AMREZ.EOP.Domain/Entities/Authentications/RolePermission.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using AMREZ.EOP.Domain.Entities.Common;
|
||||
|
||||
namespace AMREZ.EOP.Domain.Entities.Authentications;
|
||||
|
||||
public sealed class RolePermission : BaseEntity
|
||||
{
|
||||
public Guid TenantId { get; set; }
|
||||
public Guid RoleId { get; set; }
|
||||
public Guid PermissionId { get; set; }
|
||||
|
||||
public Role Role { get; set; } = default!;
|
||||
public Permission Permission { get; set; } = default!;
|
||||
}
|
||||
24
AMREZ.EOP.Domain/Entities/Authentications/User.cs
Normal file
24
AMREZ.EOP.Domain/Entities/Authentications/User.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using AMREZ.EOP.Domain.Entities.Common;
|
||||
|
||||
namespace AMREZ.EOP.Domain.Entities.Authentications;
|
||||
|
||||
public sealed class User : BaseEntity
|
||||
{
|
||||
public Guid TenantId { get; set; }
|
||||
|
||||
public string PasswordHash { get; set; } = default!;
|
||||
public bool IsActive { get; set; } = true;
|
||||
|
||||
public int AccessFailedCount { get; set; }
|
||||
public DateTimeOffset? LockoutEndUtc { get; set; }
|
||||
public bool MfaEnabled { get; set; }
|
||||
public string? SecurityStamp { get; set; }
|
||||
|
||||
public ICollection<UserIdentity> Identities { get; set; } = new List<UserIdentity>();
|
||||
public ICollection<UserMfaFactor> MfaFactors { get; set; } = new List<UserMfaFactor>();
|
||||
public ICollection<UserSession> Sessions { get; set; } = new List<UserSession>();
|
||||
public ICollection<UserPasswordHistory> PasswordHistories { get; set; } = new List<UserPasswordHistory>();
|
||||
public ICollection<UserExternalAccount> ExternalAccounts { get; set; } = new List<UserExternalAccount>();
|
||||
|
||||
public ICollection<UserRole> UserRoles { get; set; } = new List<UserRole>();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using AMREZ.EOP.Domain.Entities.Common;
|
||||
using AMREZ.EOP.Domain.Shared._Users;
|
||||
|
||||
namespace AMREZ.EOP.Domain.Entities.Authentications;
|
||||
|
||||
public sealed class UserExternalAccount : BaseEntity
|
||||
{
|
||||
public Guid TenantId { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
public ExternalProvider Provider { get; set; }
|
||||
public string Subject { get; set; } = default!; // provider UID/sub
|
||||
public string? Email { get; set; }
|
||||
public DateTimeOffset LinkedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
|
||||
public User User { get; set; } = default!;
|
||||
}
|
||||
17
AMREZ.EOP.Domain/Entities/Authentications/UserIdentity.cs
Normal file
17
AMREZ.EOP.Domain/Entities/Authentications/UserIdentity.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using AMREZ.EOP.Domain.Entities.Common;
|
||||
using AMREZ.EOP.Domain.Shared._Users;
|
||||
|
||||
namespace AMREZ.EOP.Domain.Entities.Authentications;
|
||||
|
||||
public sealed class UserIdentity : BaseEntity
|
||||
{
|
||||
public Guid TenantId { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
public IdentityType Type { get; set; }
|
||||
public string Identifier { get; set; } = default!;
|
||||
public bool IsPrimary { get; set; }
|
||||
public DateTimeOffset? VerifiedAt { get; set; }
|
||||
|
||||
public User User { get; set; } = default!;
|
||||
}
|
||||
25
AMREZ.EOP.Domain/Entities/Authentications/UserMfaFactor.cs
Normal file
25
AMREZ.EOP.Domain/Entities/Authentications/UserMfaFactor.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using AMREZ.EOP.Domain.Entities.Common;
|
||||
using AMREZ.EOP.Domain.Shared._Users;
|
||||
|
||||
namespace AMREZ.EOP.Domain.Entities.Authentications;
|
||||
|
||||
public sealed class UserMfaFactor : BaseEntity
|
||||
{
|
||||
public Guid TenantId { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
public MfaType Type { get; set; }
|
||||
public string? Label { get; set; }
|
||||
|
||||
public string? Secret { get; set; } // TOTP secret (encrypt at rest)
|
||||
public string? PhoneE164 { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? PublicKey { get; set; } // WebAuthn
|
||||
public string? CredentialId { get; set; } // WebAuthn
|
||||
|
||||
public bool Enabled { get; set; } = true;
|
||||
public DateTimeOffset AddedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
public DateTimeOffset? LastUsedAt { get; set; }
|
||||
|
||||
public User User { get; set; } = default!;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using AMREZ.EOP.Domain.Entities.Common;
|
||||
|
||||
namespace AMREZ.EOP.Domain.Entities.Authentications;
|
||||
|
||||
public sealed class UserPasswordHistory : BaseEntity
|
||||
{
|
||||
public Guid TenantId { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
public string PasswordHash { get; set; } = default!;
|
||||
public DateTimeOffset ChangedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
|
||||
public User User { get; set; } = default!;
|
||||
}
|
||||
13
AMREZ.EOP.Domain/Entities/Authentications/UserRole.cs
Normal file
13
AMREZ.EOP.Domain/Entities/Authentications/UserRole.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using AMREZ.EOP.Domain.Entities.Common;
|
||||
|
||||
namespace AMREZ.EOP.Domain.Entities.Authentications;
|
||||
|
||||
public sealed class UserRole : BaseEntity
|
||||
{
|
||||
public Guid TenantId { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
public Guid RoleId { get; set; }
|
||||
|
||||
public User User { get; set; } = default!;
|
||||
public Role Role { get; set; } = default!;
|
||||
}
|
||||
20
AMREZ.EOP.Domain/Entities/Authentications/UserSession.cs
Normal file
20
AMREZ.EOP.Domain/Entities/Authentications/UserSession.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using AMREZ.EOP.Domain.Entities.Common;
|
||||
|
||||
namespace AMREZ.EOP.Domain.Entities.Authentications;
|
||||
|
||||
public sealed class UserSession : BaseEntity
|
||||
{
|
||||
public Guid TenantId { get; set; }
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
public string RefreshTokenHash { get; set; } = default!;
|
||||
public DateTimeOffset IssuedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
public DateTimeOffset? ExpiresAt { get; set; }
|
||||
public DateTimeOffset? RevokedAt { get; set; }
|
||||
|
||||
public string? DeviceId { get; set; }
|
||||
public string? UserAgent { get; set; }
|
||||
public string? IpAddress { get; set; }
|
||||
|
||||
public User User { get; set; } = default!;
|
||||
}
|
||||
Reference in New Issue
Block a user