docs: align auth model example with Identity layers (#386)
Heimdall Gitea / Detect CI scope (push) Successful in 6s
Heimdall Gitea / Build and tests (push) Skipped
Heimdall Gitea / Build and scan server image (push) Skipped
Heimdall Gitea / Build and scan agent image (push) Skipped
Heimdall Gitea / Build and scan NVIDIA Agent image (push) Skipped
Heimdall Gitea / Publish versioned installer release (push) Skipped
Heimdall Gitea / CI policy (push) Successful in 1s
Heimdall Gitea / Detect CI scope (push) Successful in 6s
Heimdall Gitea / Build and tests (push) Skipped
Heimdall Gitea / Build and scan server image (push) Skipped
Heimdall Gitea / Build and scan agent image (push) Skipped
Heimdall Gitea / Build and scan NVIDIA Agent image (push) Skipped
Heimdall Gitea / Publish versioned installer release (push) Skipped
Heimdall Gitea / CI policy (push) Successful in 1s
Co-authored-by: Arnaud Dartois <admin@tordais.cc>
This commit was merged in pull request #386.
This commit is contained in:
1 parent
1e84000749
commit
8f3d75680d
2 files changed
+21
-9
No files matched your search
+19
-9
@@ -34,26 +34,36 @@ Voir la matrice de permissions et la section sur `ICameraAccessService` ci-desso
|
||||
## 2. Modèle de données
|
||||
|
||||
```csharp
|
||||
// IdentityUser de base — pas de modification
|
||||
public class User : IdentityUser<Guid>
|
||||
// Infrastructure/Identity/IdentityAppUser.cs
|
||||
// La classe Identity et ses dépendances restent dans Infrastructure.
|
||||
public sealed class IdentityAppUser : IdentityUser<Guid>
|
||||
{
|
||||
public string DisplayName { get; set; } = string.Empty;
|
||||
public ThemeMode Theme { get; set; } = ThemeMode.Auto;
|
||||
public string? Theme { get; set; } = "Auto";
|
||||
public string Language { get; set; } = "fr";
|
||||
public bool TwoFactorEnabled { get; set; } = false; // TOTP
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public bool MustChangePassword { get; set; }
|
||||
}
|
||||
|
||||
// Relation User → Sites (N-N)
|
||||
// Domain/Entities/UserSite.cs — aucune navigation vers le type Identity.
|
||||
public class UserSite
|
||||
{
|
||||
public Guid UserId { get; set; }
|
||||
public User User { get; set; } = null!;
|
||||
public Guid UserId { get; private set; }
|
||||
public Guid SiteId { get; private set; }
|
||||
public Site Site { get; private set; } = null!;
|
||||
|
||||
public Guid SiteId { get; set; }
|
||||
public Site Site { get; set; } = null!;
|
||||
private UserSite() { } // EF Core
|
||||
|
||||
public UserSite(Guid userId, Guid siteId)
|
||||
{
|
||||
UserId = userId;
|
||||
SiteId = siteId;
|
||||
}
|
||||
}
|
||||
|
||||
// Infrastructure/Data/Configurations/UserSiteConfiguration.cs — relation seulement.
|
||||
builder.HasOne<IdentityAppUser>().WithMany().HasForeignKey(us => us.UserId);
|
||||
|
||||
// Rôles prédéfinis
|
||||
public static class AppRoles
|
||||
{
|
||||
|
||||
@@ -9,6 +9,8 @@ Read `AGENTS.md`, the focused Gitea issue and [the Gitea ticket workflow](../git
|
||||
|
||||
When maintaining `docs/auth-roles.md`, verify its role names and default permission summaries against `Infrastructure/Security/AppPermissions.cs` and `Domain/Enums/UserRole.cs`. Heimdall has `Admin`, `Supervisor`, and `Viewer`; site/camera access is separately enforced through resource-access services, not represented by a generic `User` role. Keep the authentication summary in `docs/README.md` aligned with that guide and model.
|
||||
|
||||
Verify identity model examples against `Infrastructure/Identity/IdentityAppUser.cs`, `Domain/Entities/UserSite.cs`, and `Infrastructure/Data/Configurations/UserSiteConfiguration.cs`. Keep ASP.NET Identity in Infrastructure; `UserSite` stores the user ID without an Identity navigation, and Infrastructure maps that foreign key.
|
||||
|
||||
- Identity owns password hashing, normalized account lookup, role membership, lockout, authenticator tokens, and email/password tokens. Do not duplicate password or token cryptography in Heimdall.
|
||||
- Keep ASP.NET Core Identity packages and types inside Infrastructure. Domain must not reference Identity; Application uses `IIdentityAccountService` and `IdentityAccount` only. Put Identity EF entities (`IdentityAppUser`, `IdentityAppRole`) and `UserManager`/`RoleManager` adapters in Infrastructure. Keep user-related Domain relationships keyed by `Guid UserId`; configure their foreign keys to the Infrastructure user entity.
|
||||
- When creating an Identity user, copy the generated `SecurityStamp` back into the application account before building the first session/JWT. Cover bootstrap and regular user creation with a relational session validation test.
|
||||
|
||||
Reference in new issue
Block a user