| | | 1 | | using System.ComponentModel.DataAnnotations; |
| | | 2 | | using ArturRios.Data.Relational.Core.Entities; |
| | | 3 | | |
| | | 4 | | namespace ArturRios.Heimdall.Domain.Entities; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// A scope-specific permission that can be created, read, updated, and deleted within a |
| | | 8 | | /// <see cref="Scope" />. The <see cref="IncludeAsJwtClaim" /> flag controls whether the |
| | | 9 | | /// permission's <see cref="Name" /> is folded into the acting identity's JWT as a claim at |
| | | 10 | | /// login. A scope's permissions are managed by that scope's owners or a System Admin. |
| | | 11 | | /// </summary> |
| | | 12 | | public class ScopePermission : Entity<long> |
| | | 13 | | { |
| | | 14 | | /// <summary> |
| | | 15 | | /// External identifier, generated on creation and used everywhere the permission is |
| | | 16 | | /// addressed from outside the database (API paths, response bodies). The internal |
| | | 17 | | /// <see cref="Entity{TKey}.Id" /> is never exposed to callers. |
| | | 18 | | /// </summary> |
| | 566 | 19 | | public Guid PublicId { get; set; } = Guid.NewGuid(); |
| | | 20 | | |
| | | 21 | | /// <summary>Permission display name. Required, max 200 characters.</summary> |
| | | 22 | | [MaxLength(200)] |
| | 410 | 23 | | public string Name { get; set; } = string.Empty; |
| | | 24 | | |
| | | 25 | | /// <summary>Optional description of the permission's purpose. Max 500 characters.</summary> |
| | | 26 | | [MaxLength(500)] |
| | 218 | 27 | | public string? Description { get; set; } |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// When <c>true</c>, this permission's <see cref="Name" /> is added as a claim on the JWT |
| | | 31 | | /// issued to identities acting within the owning scope. Defaults to <c>false</c>. |
| | | 32 | | /// </summary> |
| | 216 | 33 | | public bool IncludeAsJwtClaim { get; set; } |
| | | 34 | | |
| | | 35 | | /// <summary>Logical deletion flag. Logically deleted permissions are excluded from default queries.</summary> |
| | 246 | 36 | | public bool IsDeleted { get; set; } |
| | | 37 | | |
| | | 38 | | /// <summary>Foreign key to the owning <see cref="Scope" /> (internal Id). Required.</summary> |
| | 214 | 39 | | public long ScopeId { get; set; } |
| | | 40 | | |
| | | 41 | | /// <summary>Creation timestamp.</summary> |
| | 106 | 42 | | public DateTime CreatedAt { get; set; } |
| | | 43 | | |
| | | 44 | | /// <summary>Last update timestamp.</summary> |
| | 128 | 45 | | public DateTime UpdatedAt { get; set; } |
| | | 46 | | |
| | | 47 | | // Navigation properties |
| | | 48 | | |
| | | 49 | | /// <summary>The scope this permission belongs to.</summary> |
| | 140 | 50 | | public Scope Scope { get; set; } = null!; |
| | | 51 | | } |