Commit Graph
38 Commits
Author SHA1 Message Date
Arnaud Dartois 600c96c9ff feat(app): add UserCameraAccess CRUD API and UI infrastructure (issues #131, #133, #134)
- Domain: UserCameraAccess entity with IAuditableEntity (CreatedAt, UpdatedAt)
- Application: CQRS commands/queries for camera access management
  - CreateUserCameraAccessCommand (site-wide or specific camera)
  - DeleteUserCameraAccessCommand
  - UpdateUserCameraAccessCommand (change camera/scope)
  - ListUserCameraAccessQuery / ListUserCameraAccessByCameraQuery
  - GetUserCameraAccessQuery
- DTOs: UserCameraAccessResponse, CreateUserCameraAccessRequest, UpdateUserCameraAccessRequest
- Web: UserCameraAccessController with REST endpoints
- Mapping: AutoMapper profile for UserCameraAccess
- All 1700+ tests pass
2026-10-10 21:56:03 +02:00
Arnaud Dartois e6e8690588 feat(security): add ICameraAccessService for granular per-user camera access control (#178) 2026-08-30 09:48:47 +02:00
Arnaud Dartois b97d3bec11 feat(security): enforcement — filtrage caméra dans les endpoints sensibles (#175) 2026-08-27 20:28:41 +02:00
Arnaud Dartois 0f47236c08 feat: journal d'audit complet + auto-update agent natif & Docker (#92 #96 #97) 2026-08-27 18:56:57 +02:00
Arnaud Dartois e0290c8a1b feat(db): partitionnement camera_events + gestion automatique des partitions mensuelles (#164) 2026-08-27 00:31:12 +02:00
Arnaud Dartois 6eae4eea2f feat(agent): détection GPU + heartbeat étendu + badges Admin UI (#160) 2026-08-26 23:52:16 +02:00
Arnaud Dartois ca43c6d28e feat(analysis): scheduler de jobs d'analyse avec routage par capacités, priorités et dead-letter (#159) 2026-08-26 23:44:38 +02:00
Arnaud Dartois 7a89a97bf3 feat(notifications): add user-configurable ntfy to 2026-08-20 18:14:46 +02:00
Arnaud Dartois 6b611e908a feat(notifications): abonnement par type d'événement + priorité ntfy (Fixes #61) (#154)
## Contexte

Issue #61 : Gestion des types d'alertes — abonnement par type d'événement + sévérité/priorité.

Les utilisateurs ne peuvent pas filtrer quelles notifications push/email ils reçoivent. Tous les événements (mouvement, personne, caméra hors ligne...) sont envoyés sans distinction.

## Changements

### Domaine
- **EventTypePriorityMap** (`src/Heimdall.Domain/Helpers/`) : mapping `EventType` → priorité ntfy (1-5)
  - CameraOffline/UnknownPerson = 5 (urgent), PersonDetected/FaceRecognized = 4 (high), MotionDetected/VehicleDetected/LicensePlateDetected = 3 (default), CameraOnline = 2 (low)
- **UserNotificationConfig** : ajout `SubscribedEventsJson` (JSON array), `GetSubscribedEvents()`, `IsEventTypeSubscribed()`, `SetSubscribedEvents()`
  - `null` ou `[]` = recevoir tous les événements (comportement par défaut)

### Infrastructure
- **NotificationService.DispatchToExternalChannelsAsync** : filtre par `IsEventTypeSubscribed()` avant envoi email/ntfy
- Priorité ntfy calculée via `EventTypePriorityMap.GetPriority()` et passée à `NtfyService`

### UI (Profile.razor)
- Checkboxes par type d'événement dans la section Notifications
- Texte explicatif : « Si aucun n'est sélectionné, tous les événements sont notifiés »
- Sauvegarde via `UpdateNotificationConfigRequest.SubscribedEvents`

### Tests
- 10 tests Domain : `UserNotificationConfig` (GetSubscribedEvents, IsEventTypeSubscribed, cas limites JSON invalide/vidé/unknown)
- 1 test Domain : `EventTypePriorityMap` (couvre les 8 EventTypes + null)
- 3 tests Infrastructure : filtrage par abonnement + priorité ntfy + filtre vide

## Vérification

- `dotnet build` : 0 erreur, 0 warning
- Domain.Tests : 161 passed
- Infrastructure.Tests : 180 passed
- Application.Tests : 421 passed
- Web.Tests : 243 passed
- Agent.Tests : 206 passed
- Total : 1211 tests ✅

Closes #61

Reviewed-on: https://forgejo.tordais.cc/nonobis/Heimdall/pulls/154
2026-08-20 15:10:37 +02:00
Arnaud Dartois 4792b69e46 feat(agent): télémétrie inventaire matériel — CPU/mémoire/disque/GPU/OS/réseau (Fixes #82 #83 #84 #85) (#137)
## Contexte

Implémentation des tickets #82, #83, #84, #85 — télémétrie inventaire matériel agent. L'objectif est de fournir au central un maximum d'informations sur les machines des agents (CPU, mémoire, disques, GPU, OS, réseau, conteneur) sans SSH.

## Changements

### Nouveaux collecteurs (src/Heimdall.Agent/Services/)
- **CpuInfoProvider** : parse `/proc/cpuinfo` (vendor, modèle, cœurs physiques/logiques, fréquence, flags AVX/AVX2/FMA/AVX512, cache), topologie, détection cgroup CPU (`/sys/fs/cgroup/cpu.max` v2)
- **DiskInventoryProvider** : énumère les montages (`/proc/mounts`), capacité/libre/type SSD/HDD via `/sys/block/*/queue/rotation`
- **GpuInventoryProvider** : nvidia-smi, sysfs DRM, vainfo, rocm-smi avec fallback silencieux, multi-GPU
- **HostInfoProvider** : os-release, uname, `/proc/uptime` (uptime machine ≠ process), températures sysfs
- **ContainerInfoProvider** : détection Docker (/.dockerenv, cgroup), ID conteneur, limites CPU/mémoire

### Refonte SystemMetricsProvider
- Séparation host vs process (RAM machine ≠ RAM conteneur ≠ WorkingSet64)
- Uptime machine (`/proc/uptime`) distinct de l'uptime process
- Mémoire swap

### Entité Agent + Migration
- Champs structurés CPU/mémoire/disque/GPU/OS/réseau (tous nullable, rétrocompatible)
- Migration EF `AddAgentTelemetryInventory`

### Transport heartbeat
- Inventaire au register + refresh périodique (5 min, pas à chaque tick)
- Champs JSON pour listes (disques, GPU, interfaces réseau, températures)

### UI Admin (AgentDetail.razor)
- Sections CPU, Mémoire/Disques, GPU, Machine/Conteneur avec barres de progression et badges

### Tests
- 40+ tests unitaires : providers, handlers, entité Agent
- Total : 999 tests verts (Domain 149, Application 397, Agent 210, Web 243)

## Tickets liés
- Fixes #82 — CPU inventory
- Fixes #83 — Mémoire & disque
- Fixes #84 — GPU inventory
- Fixes #85 — OS, conteneur, réseau

## Résultats des tests
- `dotnet build` : 0 erreur, 0 warning
- Domain.Tests : 149 passed
- Application.Tests : 397 passed
- Agent.Tests : 210 passed
- Web.Tests : 243 passed
- Total : 999 tests ✅

## Checklist
- [x] `dotnet build` vert (TreatWarningsAsErrors)
- [x] Tests unitaires verts
- [x] Migration EF créée
- [x] Champs nullable (rétrocompatible)
- [x] Pas de référence Infrastructure dans les contrôleurs
- [x] Collecteurs avec fallback silencieux (pas de crash sans GPU/Docker/sysfs)

Reviewed-on: https://forgejo.tordais.cc/nonobis/Heimdall/pulls/137
2026-08-20 14:13:06 +02:00
Arnaud Dartois f7e6b0cec3 feat(vehicles): API /api/vehicles - contrôleur + recherche par plaque (#150)
Résumé

Implémentation complète de l'API Vehicles (Phase 17 spec) : contrôleur REST + handlers CQRS MediatR.

Endpoints

GET /api/vehicles - Liste avec recherche par plaque (?search=XX-XXX-XX) + pagination
GET /api/vehicles/{id} - Détail avec historique events (50 derniers) + personne associée
POST /api/vehicles - Créer un véhicule
PUT /api/vehicles/{id} - Mettre à jour + associer/dissocier une personne
DELETE /api/vehicles/{id} - Supprimer un véhicule

Fichiers modifiés/créés

- src/Heimdall.Domain/Entities/Vehicle.cs - AssignPerson accepte Guid? (permet unassign)
- src/Heimdall.Infrastructure/Security/AppPermissions.cs - VehicleRead/VehicleWrite ajoutés
- src/Heimdall.Application/DTOs/VehicleDto.cs - Response, Request, EventSummary
- src/Heimdall.Application/Vehicles/ - Commands + Queries + Mapping
- src/Heimdall.Web/Controllers/VehiclesController.cs - 5 endpoints
- tests/Heimdall.Application.Tests/Handlers/Vehicles/ - 16 tests unitaires

Tests

Build 0 erreurs 0 warnings
16 nouveaux tests unitaires
Suite complète ~1149 tests 0 échec

Closes #9

Reviewed-on: https://forgejo.tordais.cc/nonobis/Heimdall/pulls/150
2026-08-20 07:34:49 +02:00
Arnaud Dartois 566aa84bc7 chore: auto-commit 2026-08-12 20:05 [Heimdall] src/Heimdall.Agent/Services/AgentRegistrationService.cs, src/Heimdall.Agent/Services/SnapshotPipelineService.cs, src/Heimdall.Application/DTOs/SettingDto.cs, src/Heimdall.Domain/Entities/UserNotificationConfig.cs, src/Heimdall.Infrastructure/BackgroundJobs/DependencyInjection.cs… 2026-08-12 20:05:12 +02:00
Arnaud Dartois dc8a24918d feat(settings): topic ntfy par site, SMTP/ntfy/S3 globaux, DSN GlitchTip fixe + toggle (Fixes #105 #106 #107 #108)
#105 — Topic ntfy cible par site :
- Site.NtfyTopic (migration AddSiteNtfyTopic), UI création/édition SitesPage
- NotificationService.ResolveNtfyTopicAsync : topic du site sinon heimdall_{userId}

#106 — Paramètres SMTP/ntfy/S3 GLOBAUX :
- Seed + sections UI : agentScoped=false pour ntfy.*/email.*/storage.*/sentry.*
- Migration douce au démarrage : UPDATE des clés existantes en base

#107 — GlitchTip : DSN fixes (central projet 6, agent projet 7) dans appsettings,
- plus de champ DSN éditable en UI → switch sentry.enabled (nécessite redémarrage)
- Init Sentry déplacé après AddInfrastructure, lit sentry.enabled en base (fallback true)

#108 — Composants typés : MudNumericField borné (port SMTP, rétention, heartbeat),
- switch pour booléens, select pour log.level — pas de saisie libre
2026-08-12 12:18:52 +02:00
Arnaud Dartois 29ff980db5 feat(domain): entités métier Vehicle/Recording/LicensePlate/StoragePolicy + relations Event→Vehicle/Recording, Camera→StoragePolicy (Fixes #6) 2026-08-11 21:42:46 +02:00
Arnaud Dartois 59a864bdfc feat(auth): codes de récupération 2FA — 10 codes hashés à l'enrôlement, usage unique au login (Fixes #12) 2026-08-11 21:35:52 +02:00
Arnaud Dartois 0136bf33ec feat(logs): remontée des logs agents vers le central — buffer, API, UI (Fixes #50 #51 #52)
- Agent : LogBufferService (ring buffer borné, drop-oldest), AgentLoggingProvider
  (capture ILogger non-bloquante), LogSanitizer (masque password/token/secret/bearer),
  LogUploadService (batch POST /api/agents/{id}/logs, retry, drop si 400)
- Central : entité AgentLogEntry + migration AddAgentLogEntries (index AgentId+TimestampUtc),
  SubmitAgentLogsCommand (batch <= 200, entrées invalides ignorées),
  GetAgentLogsQuery (pagination, filtres niveau/période/recherche),
  endpoints POST + GET /api/agents/{id}/logs
- UI : onglet Logs dans AgentDetail (filtres, pagination, auto-refresh toggle)
- Logs agent enrichis : heartbeat succès (Debug), résolution IP (Debug)
- Tests : LogBufferServiceTests (6), AgentDetailLogsTests (4), handlers AgentLogs (8)
2026-08-11 18:51:52 +02:00
Arnaud Dartoisandnonobis f8f2b08d29 feat(agent): enrichissement ONVIF authentifié côté agent — pool chiffré via config (#49)
## What

L'enrichissement ONVIF authentifié est déplacé côté **agent**. Le pool de credentials du site (login/mdp) est exposé à l'agent via `GET /api/settings/agent/{id}` sous forme d'enveloppe AES-256-GCM (`AgentCredentialEnvelope`, clé dérivée du SHA-256 de l'API key) — déchiffrable uniquement côté agent. `NetworkCameraScanner` tente `GetDeviceInformation` avec chaque couple du pool (PasswordDigest puis PasswordText) et remonte des devices **déjà identifiés** (fabricant/modèle ONVIF + `CredentialLabel`). Le central persiste et marque le credential utilisé (`LastUsedAt`) — plus aucun appel réseau ONVIF côté central.

## Why

Le central n'est généralement **pas** sur le réseau des caméras : les appels ONVIF authentifiés qu'il faisait après réception des devices bruts échouaient. L'agent, lui, est sur le sous-réseau des caméras — c'est lui qui doit porter l'auth. Enrichissement et identification se font au moment du scan, avant la remontée.

## How

- `AgentCredentialEnvelope` (Application/Security) : AES-256-GCM, clé = SHA-256 de l'API key ; central chiffre (via l'`ApiKeyHash` stocké), agent déchiffre (via sa clé en clair).
- `GetEffectiveAgentConfigQuery` : ajoute `discovery.credentials` (pool chiffré) au dict de config.
- `SettingsController.GetEffectiveConfig` : accepte l'API key agent (vérification par site) en plus du JWT admin — corrige au passage un 403 latent sur cet endpoint.
- `NetworkCameraScanner` : probe ONVIF authentifié avec le pool (anonyme d'abord, puis chaque couple).
- `AgentCredentialStore` (mémoire, jamais sur disque) : reçoit le pool déchiffré par `ConfigReceiverService`, lu par `AgentDiscoveryService`.
- `CameraDiscoveryService` : suppression de l'enrichissement réseau ; persistance + `MarkUsed` via `CredentialLabel` ; vendor déduit du fabricant ONVIF remonté.
- `SitesController` : broadcast `ConfigReload` après add/delete credential pour que les agents re-fetch leur pool.
- Multi-agents : inchangé — upsert par (site, IP) et anti-doublon IP/MAC à la confirmation évitent les caméras en double même si un agent est éteint.

## Testing

- `dotnet build Heimdall.slnx` : 0 erreur / 0 warning.
- Application 346 verts, Agent 108 verts, Infrastructure 143 verts (hors Testcontainers).
- Web.Tests 213 verts — nouveaux bUnit : DiscoveriesPage (5) + SiteDetail credentials (4).

## Breaking Changes

Aucun changement de schéma (pas de migration). Comportement API : `GET /api/settings/agent/{id}` accepte désormais l'API key agent (accès élargi au cas d'usage prévu).

Related to #48

Co-authored-by: nonobis <nonobis@tordais.cc>
Reviewed-on: https://forgejo.tordais.cc/nonobis/Heimdall/pulls/49
2026-08-11 16:15:41 +02:00
Arnaud Dartois 0b55360ad2 feat(settings): paramètres agent-scoped + configuration agent en cartes visuelles
- Flag AgentScoped sur AppSetting (entité + migration AddAgentScopedSetting
  + DTO + commandes Create/Update + validateurs + client Web)
- Écran Configuration : toggle 'Exposé aux agents' à la création
- AgentDetail : n'affiche que les globaux agent-scoped, par catégories en
  cartes visuelles avec badge Hérité (global) / Surchargé pour cet agent,
  édition inline → crée l'override, bouton restore → retour à la valeur
  globale. Tests bUnit (3) : héritage, surcharge, réinitialisation.
- Tests validateur : aliases boolean/number/integer/dropdown
2026-08-10 20:51:57 +02:00
Arnaud Dartois 1e3322cd1a fix(agent): heartbeat X-API-Key complet + métriques temps réel + hub config
- ApiKeyAuthenticationHandler accepte l'API key via query string access_token
  sur les chemins /hubs (WebSocket SignalR ne peut pas poser de header custom)
  → le ConfigReceiverService de l'agent peut se connecter au ConfigHub
- ConfigReceiverService.FetchFullConfigAsync : X-API-Key au lieu de Bearer
- Métriques heartbeat : CpuUsagePercent/MemoryUsageBytes/DiskUsagePercent/
  UptimeSeconds + IsOffline désormais transportées jusqu'à l'entité Agent
  (migration AddAgentLiveMetrics) ; IsOffline marque l'agent Offline
  immédiatement au lieu d'attendre le timeout 90s du HeartbeatMonitorJob
- docker-compose.local.yml : override aussi l'image agent (heimdall-agent:local)

Tests : +2 unit AgentRegistrationService (X-API-Key), +2 HeartbeatHandler
(métriques, offline), +3 intégration SignalR (ConfigHub query string) — verts.
2026-08-10 10:26:31 +02:00
Arnaud Dartois f800103239 feat: remplacer Gotify par ntfy — push notifications multi-utilisateur avec isolation par topic
- Nouveau NtfyService: topic isolé par user (heimdall_{userId})
- Configuration globale Ntfy:BaseUrl + Ntfy:Token (plus de token par user)
- Renommage UserNotificationConfig: Gotify* → Ntfy*
- Migration des colonnes DB: gotify_enabled/url/token → ntfy_enabled/url
- Ajout service ntfy dans docker-compose (binwiederhier/ntfy)
- Mise à jour .env.example avec NTFY__BASE_URL et NTFY__TOKEN
- Suppression GotifyService et IGotifyService
2026-07-27 04:56:16 +00:00
Arnaud Dartois f9be0f1e0d feat: implémenter SignalR hubs (Monitoring, Notifications, Admin) + système de notifications complet
SignalR Hubs:
- MonitoringHub (/hubs/monitoring) — statuts agents/caméras/stockage/GPU jobs
- NotificationsHub (/hubs/notifications) — notifications in-app badge temps réel
- AdminHub (/hubs/admin) — broadcast changements config (Admin only)

Notification System:
- Nouvelles entités: Notification, NotificationTemplate, UserNotificationConfig
- CQRS/MediatR: 6 handlers (list, unread, mark-read, mark-all, config get/update)
- Infrastructure: NotificationService orchestrator + EmailService + GotifyService
- Rate limiter IMemoryCache (20 events/min/camera/type)
- Hangfire jobs: SendNotification, DailyDigest, WeeklyDigest
- NotificationsController API (6 endpoints)
- Blazor UI: NotificationsPage + NotificationBadge
- Migration AddNotifications (3 nouvelles tables)
- 644 nouveaux tests (Domain: 131, Application: 321, Infra: 151, Integration: 120, +autres)
2026-07-26 20:45:35 +00:00
Arnaud Dartois 53e0d4c199 fix: resolve CI test failures after InMemory->Testcontainers migration
Three issues fixed:
- Camera.AssignAgent(Guid.Empty) violated FK constraint; changed to
  nullable Guid? and pass null on camera release
- Test fixtures now check DATABASE_URL env var first, falling back to
  Testcontainers locally (CI has no Docker socket)
- Added database truncation before each test via IAsyncLifetime to
  prevent shared state between test methods (InMemory was fresh per test,
  real PostgreSQL persists data)
2026-07-21 17:46:32 +00:00
Arnaud Dartois 7be5d42e85 fix(identity): DB refresh tokens, auto-refresh handler, 2FA endpoints, JWT fix
- DB-backed RevokedRefreshToken entity + migration (remplace ConcurrentDictionary\n  en memoire, fonctionne en multi-instance et survive aux redemarrages)\n- TokenRefreshHandler: auto-refresh des JWT 401 via DelegatingHandler\n  (avec SemaphoreSlim pour eviter les refresh storms)\n- Fix: GenerateRefreshToken genere maintenant un JWT valide au lieu de\n  bytes aleatoires (ValidateRefreshToken attendait un JWT - flux casse)\n- Fix: Login.razor gere Requires2fa correctement (affiche champ code 2FA)\n- Ajout: endpoints POST /api/auth/2fa/enable et /2fa/disable\n- Ajout: Disable2faAsync dans IAuthService\n- Fix: GenerateTemporaryPassword garantit les 4 categories de charactere\n  (uppercase, lowercase, digit, non-alphanumeric)\n- Fix: TestFactory ajoute Jwt:RefreshKey manquant\n\nBuild: 0 errors, 0 warnings\nTests: 226/226 passed
2026-07-21 08:57:53 +00:00
Arnaud Dartois 129a6148f5 feat(persons): add person manager with known face registry and CRUD API 2026-07-19 15:28:38 +00:00
Arnaud Dartois 358443ff1a feat(events): implement camera event pipeline with AI detection storage
Adds the foundation for AI-powered detection events storage, query,
and snapshot management. Agents can POST detection events (motion,
person, vehicle, face, etc.) with confidence scores and metadata;
users can query, filter, and view event history.

- CameraEvent entity with EF Core configuration + migration
- ICameraEventService / CameraEventService with paged query + filters
- EventsController: 5 REST endpoints (create, get, query, attach snapshot, delete)
- Agent-side CameraStreamService: FFmpeg-based RTSP frame capture (foundation)
- Supports both ApiKey (agent) and JWT (user) authentication
2026-07-19 12:55:05 +00:00
Arnaud Dartois 159da2ca26 feat(assign): implement camera-to-agent assignment with failover and strategy support
Multi-agent sites need automatic camera distribution, failover when
an agent goes offline, and rebalancing when new agents join.

Adds CameraAssignment entity with audit trail, 4 assignment strategies
(RoundRobin, GpuPriority, LeastCameras, Failover), a Hangfire failover
job that checks for stale heartbeats every 60s, a discovery coordinator
for leader election, 6 REST endpoints, EF migration, and DI registration.
2026-07-19 12:20:07 +00:00
Arnaud Dartois 31f2056d48 feat(agents): add global agents page, reusable components, KPIs, admin-only security 2026-07-19 07:25:27 +00:00
Arnaud Dartois 57b51f403c feat(web): add profile, roles, groups and claims pages 2026-07-19 06:49:17 +00:00
Arnaud Dartois 7e66bb4fbb feat(discovery): add camera detection pipeline inspired by Strix
Add complete camera discovery and stream testing specification,
Domain entities, enums, DTOs, Application interfaces, and EF Core
configurations for automated ONVIF/mDNS/HTTP/ARP camera detection.

- 4 new enums: CameraDiscoveryMethod, DetectedCameraType,
  StreamProtocol, CameraCapability (flags)
- Camera entity extended with 15+ discovery/test fields
- New entities: CameraDiscoveryResult, DiscoveredStreamUrl
- DTOs: ProbeRequest/Response, StreamTestRequest/Session, etc.
- Interface: ICameraDiscoveryService (8 methods)
- EF Core configurations for all new tables + columns
- Full spec doc: docs/specifications/detection-camera.md (16 sections)
- 145 tests pass, 0 warnings

Inspiré de Strix (github.com/eduard256/Strix) — moteur de
découverte de flux IP supportant 3600+ marques, 100K+ patterns.
2026-07-18 21:15:05 +00:00
Arnaud Dartois c2837af089 feat(mvp): complete MVP hardening — API, Web, config system, SignalR, tests 2026-07-18 18:58:20 +00:00
Arnaud Dartois 076bc58e93 fix(security): implement IDataProtector-based credential encryption for CameraCredentials
- Add ICredentialProtector/DataProtectorCredentialProtector using ASP.NET Core Data Protection
- Register AddDataProtection + ICredentialProtector in Infrastructure DI
- Update CameraCredentials XML comments to reference real protector
- Add SetCredentialsAsync to CameraService with encryption
- Update ICameraService interface
2026-07-17 20:07:03 +00:00
Arnaud Dartois 369b685fef fix(domain): make AuditLog.User setter private for consistency
All other properties on AuditLog use private set.
2026-07-17 20:03:51 +00:00
Arnaud Dartois fb8f49a2f6 refactor(domain): remove redundant Camera.Update call in CreateAsync
Camera constructor now accepts Manufacturer and Model directly,
so the redundant Update() call in CameraService is no longer needed.
2026-07-17 20:03:23 +00:00
Arnaud Dartois c36978d5a1 fix(domain): encapsulate CameraCredentials with private setters and SetCredentials method
All sensitive fields (OnvifPassword, RtspPassword, etc.) had public
setters allowing uncontrolled modification. Encapsulated via private
setters with a dedicated SetCredentials() method that updates all
values atomically and sets UpdatedAt.
2026-07-17 19:30:05 +00:00
Arnaud Dartois ec45fa3c87 fix(perf): eliminate N+1 in AuditLogService by adding User navigation property
Added AppUser navigation property to AuditLog entity with EF Core
configuration (FK -> UserId, SetNull on delete). Replaced the sub-query
in AuditLogService ListAsync with a direct navigation property access,
enabling EF Core to generate a single LEFT JOIN instead of N sub-queries.

Migration: AddAuditLogUserRelation
2026-07-17 19:24:07 +00:00
Arnaud Dartois 7a71a09102 fix(api): replace lockout with MustChangePassword flag in ResetPasswordAsync
Setting LockoutEnd to UtcNow locked the user out instead of forcing
a password change. Added MustChangePassword boolean to AppUser entity
with EF Core migration. ResetPasswordAsync now sets this flag instead
of locking the account.
2026-07-17 19:21:12 +00:00
Arnaud Dartois b217c932e8 feat(mvp): implement MVP multi-site platform
Complete MVP implementation (Étape 1) covering:
- Domain: primitives (Entity<TId>, ValueObject), 10 entities, 6 enums
- EF Core: AppDbContext + Identity, 8 EntityTypeConfigurations, audit/soft-delete interceptors, initial migration
- Application: service interfaces, DTOs, FluentValidation, ServiceResult pattern
- Security: Identity + JWT + API Key multi-auth, role-based permissions, constant-time key validation
- API: Auth/Sites/Agents controllers with explicit auth scheme policies
- Workers: Hangfire PostgreSQL setup with schema isolation, HeartbeatMonitorJob
- Agent: registration service + 30s heartbeat loop
- Docker: multi-stage Dockerfiles for central + agent, docker-compose.yml
- CI/CD: GitHub Actions pipeline with build+test and Docker build
- Tests: 13 domain tests (Site, Agent, Camera entities)

Architecture decisions per deliberation council:
- API Key via AuthenticationHandler<T> (not middleware)
- Explicit [Authorize(AuthenticationSchemes)] on all endpoints
- Event/Recording/Person/Vehicle deferred from initial migration
- Hangfire compatible with .NET 10 (v1.8.17)
2026-07-16 20:53:56 +00:00
Arnaud Dartois bfb3e06bc1 feat: initialize .NET 10 Clean Architecture solution
Create Heimdall solution with 17 projects following Clean
Architecture for a maintainable and loosely coupled codebase.

src/ (9 projects):
- Domain, Domain.Primitives, Contracts (core layer, no deps)
- Application (ref. Domain) — CQRS/MediatR ready
- Infrastructure (ref. Application + Domain) — EF Core
  PostgreSQL ready
- Api, Web (Blazor), Agent, Workers (hosts, ref. Application +
  Infrastructure)

tests/ (8 projects):
- xUnit + Shouldly + NSubstitute + bUnit (Web.Tests)
- One test project per source project (Domain -> IntegrationTests)

Config: Directory.Build.props (Nullable, ImplicitUsings,
TreatWarningsAsErrors)
2026-07-16 19:09:28 +00:00