mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13:11:10 +00:00
Implements Authorization system
This commit is contained in:
1 parent
5bfb2ca212
commit
2c9c210e43
68 files changed
+2734
-336
No files matched your search
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a permission that can be assigned to roles or users within the authorization system.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("PermissionName: {PermissionName}")]
|
||||
public class PermissionEntity : IStorageEntity, IAuditableEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the permission.
|
||||
/// </summary>
|
||||
public Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the permission.
|
||||
/// </summary>
|
||||
public required string PermissionName { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of role permission associations that include this permission.
|
||||
/// </summary>
|
||||
public required ICollection<RolePermissionEntity> RolePermissions { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of user permission associations that include this permission.
|
||||
/// </summary>
|
||||
public required ICollection<UserPermissionEntity> UserPermissions { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Repository entity for a permission in the authorization system.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("RoleName: {RoleName}")]
|
||||
public class RoleEntity : IStorageEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the role.
|
||||
/// </summary>
|
||||
public Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the role.
|
||||
/// </summary>
|
||||
public required string RoleName { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of user roles associations that include this role.
|
||||
/// </summary>
|
||||
public required ICollection<UserRoleEntity> UserRoles { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of role permission associations that include this role.
|
||||
/// </summary>
|
||||
public required ICollection<RolePermissionEntity> RolePermissions { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the association between a role and a permission within the authorization system.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Role: {Role.RoleName}, Permission: {Permission.PermissionName}")]
|
||||
public class RolePermissionEntity : IStorageEntity, IAuditableEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the role permission.
|
||||
/// </summary>
|
||||
public Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Id of the role of the role permission.
|
||||
/// </summary>
|
||||
public required Guid RoleId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the role of the role permission.
|
||||
/// </summary>
|
||||
public required RoleEntity Role { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Id of the permission of the role permissions.
|
||||
/// </summary>
|
||||
public required Guid PermissionId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the permission of the role permission.
|
||||
/// </summary>
|
||||
public required PermissionEntity Permission { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the association between a user and a permission within the authorization system.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("User: {User.Username}, Permission: {Permission.PermissionName}")]
|
||||
public class UserPermissionEntity : IStorageEntity, IAuditableEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the user permission.
|
||||
/// </summary>
|
||||
public Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Id of the user of the user permission.
|
||||
/// </summary>
|
||||
public required Guid UserId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user of the user permission.
|
||||
/// </summary>
|
||||
public required UserEntity User { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Id of the permission of the user permission.
|
||||
/// </summary>
|
||||
public required Guid PermissionId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the permission of the user permission.
|
||||
/// </summary>
|
||||
public required PermissionEntity Permission { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.Common;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.DataAccess.Entities.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the association between a user and a role within the authorization system.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("User: {User.Username}, Role: {Role.RoleName}")]
|
||||
public class UserRoleEntity : IStorageEntity, IAuditableEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Id of the user role.
|
||||
/// </summary>
|
||||
public Guid Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Id of the user of the user role.
|
||||
/// </summary>
|
||||
public required Guid UserId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user of the user role.
|
||||
/// </summary>
|
||||
public required UserEntity User { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Id of the role of the user role.
|
||||
/// </summary>
|
||||
public required Guid RoleId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the role of the user role.
|
||||
/// </summary>
|
||||
public required RoleEntity Role { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
public required DateTime CreatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that created the entity.
|
||||
/// </summary>
|
||||
public required Guid CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional time and date when the entity was updated.
|
||||
/// </summary>
|
||||
public DateTime? UpdatedOnUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional Id of the user that updated the entity.
|
||||
/// </summary>
|
||||
public Guid? UpdatedBy { get; set; }
|
||||
}
|
||||
Reference in new issue
Block a user