Commit Graph
4 Commits
Author SHA1 Message Date
Arnaud Dartois 22ebcaf73a fix(web): 401 au premier rendu — cookie propagé aux appels API internes (Fixes #23)
Symptôme : après F5 sur une page authentifiée, les appels API des pages
(api/stats, api/agents…) renvoyaient 401 jusqu'à la connexion du circuit
Blazor. Cause : au rendu initial, AuthState est peuplé depuis le cookie
(AccessToken null → pas de Bearer) et le HttpClient serveur n'envoie pas
le cookie navigateur ; les contrôleurs n'acceptaient que JwtBearer.

Correctif :
- SameOriginHttpMessageHandler : propage le cookie d'authentification du
  HttpContext courant vers la requête interne quand aucun Bearer n'est
  posé (le Bearer du circuit prend le relais ensuite).
- Contrôleurs API humains : AuthenticationSchemes = 'JwtBearer,Cookies'
  (77 occurrences) — le cookie porte les mêmes claims de rôle/permission
  que le JWT.
- Vérifié en réel : F5 /dashboard → plus de snackbar 401, console propre,
  api/agents validé et 200 côté serveur. 182 tests Web verts.
2026-08-11 08:32:41 +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 1d1ac8387e feat(cqrs): update controllers, add AutoMapper profiles, SignalR notifications, Hangfire config
- 13 controllers migrated from service DI to IMediator dispatch
- 11 AutoMapper mapping profiles (Sites, Cameras, Auth, Users, Agents, Events, Assignments, Settings, Groups, Persons, Discovery)
- SignalR notifications bridged via MediatR INotificationHandler
- Hangfire config moved from Program.cs to Infrastructure/BackgroundJobs
- 0 build errors, 0 warnings
2026-07-22 19:54:55 +00:00
Arnaud Dartois 562aabdfc8 feat(api+web): merge REST API and Blazor UI into single process
Previously the API (heimdall-central) and Blazor UI (heimdall-web) ran as
separate containers with the Blazor Server making internal HTTP calls to
the API. This caused the Blazor circuit to disconnect when the API was
unreachable (network error → "Une erreur réseau est survenue").

Now both serve from the same .NET process on the same port:
- All 16 API controllers, ExceptionFilter, and SignalR hubs integrated
  into Heimdall.Web
- JWT auth, CORS, rate limiting configured in the unified Program.cs
- Dockerfile.central entrypoint runs web/Heimdall.Web.dll
- docker-compose simplified: heimdall-central service removed
- CI publishes heimdall-web image instead of heimdall-central

Also fixes timezone validation on Alpine/tzdata-less environments
and enables FluentValidation auto-validation in the API project.
2026-07-20 10:30:01 +00:00