| | | 1 | | using System.ComponentModel.DataAnnotations; |
| | | 2 | | using ArturRios.Data.Relational.Core.Entities; |
| | | 3 | | |
| | | 4 | | namespace ArturRios.Heimdall.Domain.Entities; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// A logical tenant boundary that groups the owners, users, applications, and Google Users |
| | | 8 | | /// belonging to a specific client system. |
| | | 9 | | /// </summary> |
| | | 10 | | public class Scope : Entity<long> |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// External identifier, generated on creation and used everywhere the scope is addressed |
| | | 14 | | /// from outside the database (API paths, response bodies, token claims). The internal |
| | | 15 | | /// <see cref="Entity{TKey}.Id" /> is never exposed to callers. |
| | | 16 | | /// </summary> |
| | 4946 | 17 | | public Guid PublicId { get; set; } = Guid.NewGuid(); |
| | | 18 | | |
| | | 19 | | /// <summary>Scope display name. Required, unique.</summary> |
| | | 20 | | [MaxLength(200)] |
| | 3131 | 21 | | public string Name { get; set; } = string.Empty; |
| | | 22 | | |
| | | 23 | | /// <summary>Optional description of the scope's purpose.</summary> |
| | | 24 | | [MaxLength(500)] |
| | 179 | 25 | | public string? Description { get; set; } |
| | | 26 | | |
| | | 27 | | /// <summary>Logical deletion flag. Logically deleted scopes are excluded from default queries.</summary> |
| | 1187 | 28 | | public bool IsDeleted { get; set; } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Whether Google sign-up/sign-in is available for this scope. Defaults to <c>false</c>; |
| | | 32 | | /// only the scope's owners or a System Admin may toggle it. |
| | | 33 | | /// </summary> |
| | 278 | 34 | | public bool GoogleSignInEnabled { get; set; } |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Whether anonymous callers may register a password <c>User</c> in this scope (UC-47, |
| | | 38 | | /// FR-SR-01). Defaults to <c>false</c>; only the scope's owners or a System Admin may toggle it. |
| | | 39 | | /// </summary> |
| | 303 | 40 | | public bool SelfRegistrationEnabled { get; set; } |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// The lawful basis this tenant processes its users' data on (see <c>LegalBases</c>), or |
| | | 44 | | /// <c>null</c> to take the deployment default of contract performance. |
| | | 45 | | /// </summary> |
| | | 46 | | /// <remarks> |
| | | 47 | | /// The scope is where this belongs because the scope is the tenant boundary, and in most |
| | | 48 | | /// deployments the tenant organisation is the controller for the identities inside it (Data |
| | | 49 | | /// Protection Document §3). One deployment-wide basis would assert something about every |
| | | 50 | | /// tenant that only each tenant can know. |
| | | 51 | | /// </remarks> |
| | 152 | 52 | | public int? DefaultLegalBasis { get; set; } |
| | | 53 | | |
| | | 54 | | /// <summary> |
| | | 55 | | /// Where this tenant's own privacy notice is published, or <c>null</c> if it has none |
| | | 56 | | /// distinct from Heimdall's. |
| | | 57 | | /// </summary> |
| | | 58 | | /// <remarks> |
| | | 59 | | /// GDPR Art. 13 and LGPD Art. 9 oblige the controller to inform the data subject, and for a |
| | | 60 | | /// scope's users that controller is the tenant. Carrying the URI here lets a client system |
| | | 61 | | /// show the right notice at sign-up without hard-coding it. |
| | | 62 | | /// </remarks> |
| | | 63 | | [MaxLength(2048)] |
| | 96 | 64 | | public string? PrivacyNoticeUri { get; set; } |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// Base link the verification token is appended to in the emails sent to this scope's |
| | | 68 | | /// <c>User</c>s (sign-up confirmation and address verification), or <c>null</c> to use the |
| | | 69 | | /// deployment-wide <c>HEIMDALL_EMAIL_VERIFICATION_URL</c>. |
| | | 70 | | /// </summary> |
| | | 71 | | /// <remarks> |
| | | 72 | | /// A client system has its own screens for these steps, and its users' links must lead |
| | | 73 | | /// there rather than to Heimdall's. Administrators have no scope and always take the global |
| | | 74 | | /// link. |
| | | 75 | | /// </remarks> |
| | | 76 | | [MaxLength(2048)] |
| | 200 | 77 | | public string? EmailVerificationUrl { get; set; } |
| | | 78 | | |
| | | 79 | | /// <summary> |
| | | 80 | | /// Base link the reset token is appended to in the password-reset emails sent to this scope's |
| | | 81 | | /// <c>User</c>s, or <c>null</c> to use the deployment-wide <c>HEIMDALL_PASSWORD_RESET_URL</c>. |
| | | 82 | | /// Administrators have no scope and always take the global link. |
| | | 83 | | /// </summary> |
| | | 84 | | [MaxLength(2048)] |
| | 149 | 85 | | public string? PasswordResetUrl { get; set; } |
| | | 86 | | |
| | | 87 | | /// <summary>Creation timestamp.</summary> |
| | 121 | 88 | | public DateTime CreatedAt { get; set; } |
| | | 89 | | |
| | | 90 | | /// <summary>Last update timestamp.</summary> |
| | 154 | 91 | | public DateTime UpdatedAt { get; set; } |
| | | 92 | | |
| | | 93 | | // Navigation properties |
| | | 94 | | |
| | | 95 | | /// <summary>Ownership join rows linking this scope to its owners (persons with the <c>ScopeAdmin</c> role).</summar |
| | 1840 | 96 | | public ICollection<ScopeOwner> Owners { get; set; } = new List<ScopeOwner>(); |
| | | 97 | | |
| | | 98 | | /// <summary>Membership join rows linking this scope to its users (persons with the <c>User</c> role).</summary> |
| | 1732 | 99 | | public ICollection<ScopeUser> Users { get; set; } = new List<ScopeUser>(); |
| | | 100 | | |
| | | 101 | | /// <summary>Applications contained in this scope.</summary> |
| | 1715 | 102 | | public ICollection<Application> Applications { get; set; } = new List<Application>(); |
| | | 103 | | |
| | | 104 | | /// <summary>Google Users contained in this scope.</summary> |
| | 1715 | 105 | | public ICollection<GoogleUser> GoogleUsers { get; set; } = new List<GoogleUser>(); |
| | | 106 | | |
| | | 107 | | /// <summary>Scope-specific permissions defined within this scope.</summary> |
| | 1715 | 108 | | public ICollection<ScopePermission> ScopePermissions { get; set; } = new List<ScopePermission>(); |
| | | 109 | | } |