Commit Graph
19 Commits
Author SHA1 Message Date
Arnaud Dartois 2b41ab4ea3 fix(storage): record historical object destinations
Heimdall Gitea / Build and tests (pull_request) Failing after 4m57s
Heimdall Gitea / Publish versioned release (pull_request) Skipped
2026-10-22 19:58:55 +02:00
Arnaud Dartois 434a3f0822 feat(app): add Group-Camera access management (issue #138)
- Domain: GroupCameraAccess entity with IAuditableEntity
- Group entity: added GroupCameraAccesses navigation collection
- Camera entity: added GroupCameraAccesses navigation collection
- Infrastructure: DbSet, configuration with unique constraint on (GroupId, CameraId)
- Application: CQRS commands/queries for group camera access
  - AddCameraToGroupCommand / RemoveCameraFromGroupCommand
  - GetCamerasByGroupQuery
- DTOs: GroupCameraAccessResponse, CreateGroupCameraAccessRequest, DeleteGroupCameraAccessRequest
- Web: GroupCamerasController with REST endpoints
- All 1700+ tests pass
2026-10-10 22:45:36 +02:00
Arnaud Dartois 80e21d63e6 fix(tests): repair PersonsController integration tests and fix EF concurrency on RegisterFace
- Add DbUpdateConcurrencyException to SaveChangesWithRetryAsync transient check
- RegisterFaceHandler adds KnownFace via DbContext Set to avoid phantom UPDATE
- Validate empty embedding (400) before person existence check
- CreateViewerClientAsync bootstraps admin first so 2nd user is Viewer
- Rename GetAll_WithViewerAuth test to match PersonRead permission on Viewer
- PersonsControllerTests: all 20 tests green
2026-10-10 19:47:09 +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 2e188e4dda chore: auto-commit 2026-08-12 10:00 [Heimdall] docs/MASTER_SPECIFICATION.md, docs/README.md, docs/codeproject-ai.md, docs/signalr-usage.md, docs/specs.md… 2026-08-12 10:00:44 +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 450e019617 feat(infra): intégration Sentry/GlitchTip complète
- Upgrade Sentry.AspNetCore v6.7.0 → v6.8.0
- Ajout Sentry base package à Infrastructure (pour SentryErrorReporter)
- Configuration SDK enrichie dans Web et Agent:
  - AutoSessionTracking=false (GlitchTip ne supporte pas)
  - EnableLogs=true (logs structurés)
  - CaptureBlockingCalls=true (détection .Result/.Wait())
  - CaptureFailedRequests=true (capture 4xx/5xx HttpClient)
  - IncludeActivityData=true (DiagnosticSource)
  - SetBeforeSend pour nettoyage PII (password, token, secret)
  - SetBeforeBreadcrumb pour filtrage breadcrumbs
  - SampleRate, AttachStacktrace, MaxBreadcrumbs configurés
  - Release depuis la config, Environment auto
  - StackTraceMode.Enhanced
  - double.Parse avec CultureInfo.InvariantCulture
  - UseSentry avec type explicite SentryAspNetCoreOptions
- Abstraction IErrorReporter dans Application (0 dép. Sentry)
- Implémentation SentryErrorReporter dans Infrastructure
- Enregistrement DI dans Infrastructure
- DSN de développement dans appsettings.Development.json
- .env.example avec Sentry__Dsn et Sentry__TracesSampleRate
2026-07-28 14:52:52 +00:00
Arnaud Dartois 45c6ce82eb perf: add ConfigureAwait(false) to all async calls in library projects
Add ConfigureAwait(false) to all await expressions in Application and
Infrastructure projects (111 files). This follows .NET best practices
for library code to avoid potential deadlocks when consumed from
synchronization contexts (legacy, unit test runners).

Also fix 4 test assertions that check SaveChangesAsync — update to
SaveChangesWithRetryAsync to match the handler changes from Fix 4.
2026-07-27 18:59:12 +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 1a6f2b037f fix(cqrs): restore ServiceResult encapsulation, use factory methods in ValidationBehavior
- Revert ServiceResult to protected set + protected constructors
- Remove new() constraint from ValidationBehavior
- Use static Failure() factory method via reflection instead
2026-07-22 20:32:45 +00:00
Arnaud Dartois 55620b0776 fix(cqrs): address code review findings
Critical fixes:
- Publish EventCreatedNotification (SignalR broadcast was broken)
- Use ValidateAsync in ValidationBehavior (async validators were skipped)

Important fixes:
- Remove dead UnitOfWorkBehavior (handlers manage saves themselves)
- Remove dead ConfigChangedNotification (controller broadcasts directly)
- Guard MappingProfile Activator.CreateInstance against missing ctor
- Add CA1711 pragma with justification
2026-07-22 20:22:34 +00:00
Arnaud Dartois c1b3b3d3b4 feat(cqrs): migrate Events, Agents, Assignments, Discovery, Others to CQRS
- Events: CRUD commands/queries + EventCreatedNotification for SignalR
- Agents: Register (with API key gen), Heartbeat, queries
- Assignments: Assign, Failover, Release commands + queries
- Discovery: 10 handlers delegating to existing probes/services
- Groups/Persons/Settings/Audit/Stats: full CQRS for remaining domains
- Extend IApplicationDbContext with all DbSets
2026-07-22 19:48:16 +00:00
Arnaud Dartois 11f7fd8d20 feat(cqrs): migrate Sites, Auth, Users, Cameras to CQRS
- Sites: CreateSite, UpdateSite, DeleteSite, GenerateToken commands + handlers
- Auth: Login, Register, RefreshToken, 2FA, ChangePassword, Logout commands
- Users: CRUD, roles, sites, lock/unlock, reset-password commands + queries
- Cameras: CRUD, SetCredentials commands + queries
- Add IApplicationDbContext abstraction for Clean Architecture
- Add ICredentialProtector, IJwtService interfaces to Application layer
- 0 build errors, 0 warnings
2026-07-22 19:43:13 +00:00
Arnaud Dartois 649af93f56 feat(cqrs): add MediatR, AutoMapper and pipeline infrastructure
- Add MediatR 12.5.0, AutoMapper 13.0.1 packages
- Create ValidationBehavior (FluentValidation pipeline)
- Create LoggingBehavior (structured logging pipeline)
- Create MappingProfile with IMapFrom<T> convention
- Make ServiceResult properties public for pipeline use
- Update Application DI with MediatR + AutoMapper registration
2026-07-22 19:31:51 +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