Initial commit with inital CMS
This commit is contained in:
+52
@@ -0,0 +1,52 @@
|
||||
# Database Design — Unit 02: Identity & RBAC
|
||||
|
||||
Dit document beschrijft de database schema configuratie voor de identiteitsmodule.
|
||||
|
||||
## 1. DbContext Mapping (Identity)
|
||||
|
||||
De `ApplicationDbContext` erft over van `IdentityDbContext<ApplicationUser, IdentityRole<Guid>, Guid>`.
|
||||
In `OnModelCreating` worden de tabelnamen geconfigureerd:
|
||||
|
||||
```csharp
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
builder.Entity<ApplicationUser>(entity => { entity.ToTable("Users"); });
|
||||
builder.Entity<IdentityRole<Guid>>(entity => { entity.ToTable("Roles"); });
|
||||
builder.Entity<IdentityUserRole<Guid>>(entity => { entity.ToTable("UserRoles"); });
|
||||
builder.Entity<IdentityUserClaim<Guid>>(entity => { entity.ToTable("UserClaims"); });
|
||||
builder.Entity<IdentityUserLogin<Guid>>(entity => { entity.ToTable("UserLogins"); });
|
||||
builder.Entity<IdentityRoleClaim<Guid>>(entity => { entity.ToTable("RoleClaims"); });
|
||||
builder.Entity<IdentityUserToken<Guid>>(entity => { entity.ToTable("UserTokens"); });
|
||||
}
|
||||
```
|
||||
|
||||
## 2. Aanvullende Tabellen
|
||||
|
||||
### RefreshTokens
|
||||
- **Tabel**: `RefreshTokens`
|
||||
- **PK**: `Id` (Guid)
|
||||
- **FK**: `UserId` -> `Users.Id`
|
||||
- **Index**: `Token` (Unique)
|
||||
|
||||
### Invitations
|
||||
- **Tabel**: `Invitations`
|
||||
- **PK**: `Id` (Guid)
|
||||
- **Index**: `Token` (Unique)
|
||||
- **Email**: `NVARCHAR(256)`
|
||||
|
||||
### ModulePermissions
|
||||
- **Tabel**: `ModulePermissions`
|
||||
- **Composite PK**: `(UserId, ModuleName, Permission)`
|
||||
- **FK**: `UserId` -> `Users.Id`
|
||||
|
||||
## 3. Auditing (NFR-ID-SEC-03)
|
||||
|
||||
Er wordt een aparte `AuditLogs` tabel aangemaakt voor het loggen van mutaties:
|
||||
- `Id` (Guid)
|
||||
- `Timestamp` (DateTimeOffset)
|
||||
- `ActorId` (Guid - De uitvoerder)
|
||||
- `Action` (String - bijv. "RoleChange", "UserCreated")
|
||||
- `EntityId` (Guid - Het doelobject)
|
||||
- `Details` (JSON/String - Oude vs Nieuwe waarden)
|
||||
Reference in New Issue
Block a user