## What
Complète le paramétrage des notifications ntfy (serveur + utilisateur, UI + backend).
## Why
L'issue #60 demandait un paramétrage complet. Le code existant avait des bugs et des manques :
- Le lookup DB de l'URL ntfy ratait à cause d'un mismatch de casing (`ntfy.baseUrl` vs `ntfy.baseurl`)
- L'override URL par utilisateur (`UserNotificationConfig.NtfyUrl`) n'était jamais utilisé lors de l'envoi
- La page profil n'affichait pas le topic ntfy à s'abonner
- Le test ntfy n'envoyait pas le topic de l'utilisateur
## Changes
- **Fix casing** : `NtfyService.ResolveConfigAsync` lit maintenant `ntfy.baseurl` (lowercase) pour correspondre à ce que l'UI écrit
- **Per-user URL override** : `INtfyService` accepte un `baseUrl` optionnel ; `NotificationService` passe `config.NtfyUrl` lors de l'envoi
- **Profile.razor** : affiche le topic ntfy personnalisé (`heimdall_{userId}`) + bouton "Tester ntfy" qui envoie vers le topic de l'utilisateur
- **HeimdallApiClient** : `TestNtfyAsync` accepte et envoie le topic dans le body
- **SendNotificationJob** : transmet le paramètre `baseUrl`
## Testing
- `dotnet build` : 0 erreurs, 0 warnings
- 963 tests unitaires passent (Domain 142, Application 391, Infrastructure 177, Agent 197, Web 243, Api 2)
Closes#60
Reviewed-on: https://forgejo.tordais.cc/nonobis/Heimdall/pulls/152
- Source de vérité DB (ntfy.*, email.*, ai.cpaiUrl, ai.ollamaUrl) avec
fallback config/env pour migration douce — relu à chaque appel, une
modification UI est prise en compte sans redémarrage
- Nouveau helper AppSettingReader (lecture async + parse int/bool, silencieux
si DB indisponible), pattern StorageProviderFactory (scope + DbContext)
- Les env vars restent en fallback uniquement
- Agent : 22 ports probés (ajout 8080/5544/10554/1935/81/88/8090/8001/8081/7070/7447/51826)
- CameraStreamTemplates : port par défaut par schéma (rtsp=554, rtmp=1935, http=80,
dvrip=34567, bubble=80), filtre de compatibilité protocole → les URLs ne portent
plus de ports incohérents (ex. RTSP sur :80) ; plus de forçage de ports[0]
- Nouveaux templates : p:rtmp, b:uniview (bubble), b:reolink, dvrip:// dans p:dvrrip/b:dahua
- ProtocolFromUrl : Dvrip/Bubble/HomeKit reconnus côté central
- Tests : 9 tests unitaires CameraStreamTemplates
- Compose (dev+prod): agent on host network (bridge 172.x was skipped by the
scanner), listen on 8081 (ntfy owns 8080), CentralUrl via host/domain,
healthcheck adapted, no Docker DNS
- Scanner: skip the LAN gateway (NAT router, never a camera); wider camera
ports (+34567/34568 Imou SDK, +8000 Hikvision SDK); 750 ms port timeout;
keep only devices with real camera evidence; RTSP OPTIONS + MJPEG
content-type probes prove live streams from the agent (it is on the LAN)
- Central: drop Unknown devices (nginx/gunicorn/gateway) on submit; classify
37777 DVRIP as Standard camera (not NVR), 8899 alone as NVR; persist
agent-tested stream URLs flagged IsAlive; shared CameraStreamTemplates
with the agent so both build identical candidate URLs
- UI: discoveries popup auto-selects the agent-verified main stream — no
manual stream choice
## 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
- 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
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.
- 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
- Remove 13 old service interfaces from Application/Services
- Remove 13 old service implementations from Infrastructure/Services
- Remove old SnapshotService (no CQRS replacement needed)
- Update Infrastructure DI to register only CQRS-compatible services
- Preserve CameraEventService + PersonService for existing tests
- Clean up duplicate IUserRepository registration
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)
Add ILogger<AuthService> with log events at every step:
register, login, 2FA, refresh token, password change,
logout, admin registration. All error paths now log
the exact failure reason (validation, Identity errors,
public registration disabled, etc.).
Previously all errors were silently swallowed by the
HeimdallApiClient returning null on non-success responses.
- First registered user is auto-assigned Admin role (empty DB)
- Add auth.public-registration.enabled setting to disable public
registration (only admins can create users via POST /api/users)
- Add DELETE /api/users/{id} endpoint (Admin only) with guards:
- Cannot delete own account
- Cannot delete the last administrator
- Guard AssignRolesAsync to prevent removing Admin from last admin
- Add AuthSettings constants class for well-known setting keys
Adds S3-compatible snapshot storage (Alarik) with AWS Signature V4,
upload, thumbnail, and delete operations. Backfills Phase 2 & 3 with
27 new tests covering camera assignment strategies, event CRUD with
filtering, snapshot attachment, and API contract validation.
- SnapshotService with S3 REST API via HttpClient + SigV4 signing
- 10 unit tests for CameraAssignmentService (assign, release, failover, history)
- 9 unit tests for CameraEventService (create, query, filter, delete, snapshot)
- 8 integration tests for AssignmentsController + EventsController
- SnapshotService registration with 5-min timeout HTTP client