Commit Graph
50 Commits
Author SHA1 Message Date
Arnaud Dartois d6c7ca1194 fix(web): bindings MudCheckBox/MudSwitch @bind-Value (au lieu de @bind-Checked)
MudBlazor 9.x ignore silencieusement l'attribut inconnu 'Checked'
(CaptureUnmatchedValues) : les checkboxes de rôles et les switches de
configuration ne se liaient jamais. Passage à l'API Value/ValueChanged
+ mise à jour MudBlazor 9.1.0 → 9.8.0 (Web + tests). Vérifié en réel :
la case Admin est cochée à l'ouverture du dialog utilisateur.
2026-08-10 16:46:08 +02:00
Arnaud Dartois 4da72ae6f3 feat(ui): gestion des sites façon Pangolin — édition + installation agent
- Édition de site : bouton Modifier + dialog (nom/adresse/fuseau) via
  UpdateSiteAsync (nouvelle méthode client PUT api/sites/{id})
- Installation agent : nouveau SiteInstallPanel façon Pangolin avec onglets
  Docker Compose (recommandé) / Script shell, génération du compose avec le
  token du site et l'URL publique du serveur
- SitesPage : badges statut (StatusChip), boutons Modifier/Installer/Supprimer,
  header descriptif ; le flux 'Installer un agent' génère token + compose
- SiteDetail : remplace l'ancien compose manuel par SiteInstallPanel
- Tests adaptés + nouveau test d'édition (PUT + reload + snackbar)
2026-08-10 15:29:35 +02:00
Arnaud Dartois 6606cf9dd5 feat(ui): affiche les métriques live des agents (CPU, RAM, disque, uptime)
- AgentResponse expose CpuUsagePercent/MemoryUsageBytes/DiskUsagePercent/
  UptimeSeconds (mappés dans les 3 handlers GetAgent/GetAll/GetBySite)
- AgentItem client complété ; nouvelles tuiles AgentMetrics + MetricTile
  (jauges colorées) intégrées en ChildRowContent dans AllAgentsPage
2026-08-10 15:16:09 +02:00
Arnaud Dartois 79d6ec0495 fix(ui): lightbox snapshots cliquable + recherche FilterBar à la frappe
Découverts par les tests bUnit des pages :
- SnapshotsPage : OnClick était passé à MudPaper, qui n'a pas ce paramètre
  dans MudBlazor 9.7 → le clic sur une carte était silencieusement ignoré,
  la lightbox n'ouvrait jamais. Remplacé par un div cliquable (role=button,
  tabindex) autour du contenu.
- FilterBar : SearchChanged/CategoryChanged déclarés mais jamais invoqués →
  la recherche ne se déclenchait que via le submit du form. ValueChanged
  câblé pour invoquer les EventCallback à la frappe/sélection.

Tests mis à jour pour le comportement corrigé : clic carte → dialog,
recherche à la frappe → rechargement sans submit.
2026-08-10 13:17:27 +02:00
Arnaud Dartois 2d836525c2 fix(ui): affiche le nom du site et corrige les compteurs du dashboard
- AgentResponse porte désormais SiteName (GetAgent/GetAllAgents/GetBySite
  projettent a.Site.Name via Include) → la page Agents affiche 'Site
  Principal' au lieu du GUID
- GetStatsAsync désérialise l'enveloppe { data, timestamp } → les KPIs
  du dashboard (Agents en ligne, total) affichaient 0 malgré des agents
  Online ; le wrapper StatsEnvelope corrige la lecture
2026-08-10 10:53:48 +02:00
Arnaud Dartois 53b6240a3e fix(auth): répare l'authentification de bout en bout (cookie + JWT + rendu Blazor)
Anomalies corrigées :
- MudPopoverProvider manquant dans les layouts → circuit Blazor mourait sur
  l'ouverture de menus/popovers (dashboard jamais rendu après login)
- AddIdentity redéfinissait le schéma par défaut sur Identity.Application
  alors que /_auth/signin signait avec Cookies → cookie posé mais jamais
  validé, tout rechargement de page redirigeait vers /login. Forçage du
  schéma par défaut sur Cookies + schémas JwtBearer explicites sur les
  endpoints API d'AuthController et SettingsController
- Policy 'AdminUsers' utilisée par register-admin mais jamais enregistrée
  → 500 à l'appel. Ajoutée (RequireRole Admin)
- HeimdallAuthStateProvider ne lisait que le sessionStorage navigateur :
  pendant le prerender SSR, HttpContext.User (cookie) n'était pas utilisé
  → pages protégées redirigées vers /login. Fallback cookie ajouté
- SameOriginHttpMessageHandler : résolution de l'origine via
  IServerAddressesFeature quand IHttpContextAccessor est null (circuit
  Blazor post-hydratation) au lieu de heimdall.local → DNS cassé
- UpdateUserValidator rejetait le thème 'Auto' (défaut de l'UI) → 400
  à l'édition. Accepte désormais auto (case-insensitive)

Tests :
- E2E Playwright complets (login/logout/register/user management) : 33/33
- Integration (Testcontainers PostgreSQL) : 120/120 (valeur 'bool' du
  valueType, bootstrap admin via /register auto-admin, header X-API-Key,
  /proc/meminfo optionnel pour les LXC restreints)
- Exécution E2E séquentielle (xunit.runner.json) pour éliminer le flakiness
2026-08-09 23:43:11 +02:00
Arnaud Dartois 219d9b73b6 feat(ui): polish visuel global — Font Awesome, composants partagés, fix MudMenu 2026-07-27 20:11:31 +00:00
Arnaud Dartois c1eac5431b fix: corriger les 8 issues du code review notifications
🔴 EmailService: implémentation SMTP réelle (System.Net.Mail)
🔴 GetNotificationConfigHandler: CQS — retourne DTO par défaut sans écrire en DB
🟠 NotificationRateLimiter: increment atomique (Interlocked)
🟠 DailyDigestJob/WeeklyDigestJob: comptes événements user-specific
🟠 docker-compose.prod: auth ntfy via NTFY_AUTH_FILE
🟠 Namespace: Heimdall.Web.Controllers (consistant)
🟠 Commentaire 'gotify' → 'ntfy'
🟠 Tests: NotificationsControllerTests (7 tests)
2026-07-27 05:33:53 +00:00
Arnaud Dartois a379f2b136 feat(logging): add comprehensive authentication logging
- Add cookie authentication event logging in Program.cs (redirect to login, access denied, principal validation)
- Add logging in RedirectToLogin.razor for redirection tracking
- Add detailed logging in Login.razor for login attempts, 2FA verification, and authentication completion
- Add structured logging in AuthController for all authentication endpoints (register, login, 2fa, refresh, change-password, logout, etc.)
- Use appropriate log levels (Information, Warning, Error, Debug) based on event importance
2026-07-24 18:25:33 +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 940e826865 fix(identity): corrige JWT role claims, password policy, et consistency
- JWT role claims: string.Join -> ClaimTypes.Role individuels (debloque [Authorize(Roles)])\n- Password policy: RequireUppercase=true, RequireNonAlphanumeric=true\n- JWT validation params extraits en methode partagee (anti-duplication)\n- Retours 401 uniformises avec body structure\n- Champ Langue ajoute dans le dialog d'edition utilisateur\n\nBuild: 0 errors, 0 warnings\nTests: 226/226 passed
2026-07-21 08:47:24 +00:00
Arnaud Dartois 252724a2fd fix(web): handle login cookie creation failure
- Remove redundant antiforgery check from /_auth/signin and
  /_auth/signout
  (JWT validation is sufficient security; antiforgery tokens
  fail silently because the JS caller never includes one)
- Add ILogger structured logging to both endpoints
- Make AuthHelper.SignInAsync return bool so Blazor pages
  can detect failure
- Show user-friendly error messages in Login.razor and
  Register.razor when cookie creation fails
2026-07-20 17:12:16 +00:00
Arnaud Dartois b5ff5c6a99 fix(ui): add missing @key directives to all @foreach loops 2026-07-20 10:03:12 +00:00
Arnaud Dartois a33a436c26 chore: apply auto-fixes and code improvements
- AuthService: fix public registration logic revert
- JwtService: add ILogger dependency
- SoftDeleteInterceptor removed (merged)
- XML doc comments on all services
- Error boundary + error page in Blazor
- Optimize StatsService queries
- ApiClient error handling improvements
2026-07-20 09:50:43 +00:00
Arnaud Dartois 153be535d4 fix(multiple): auth, workers, EF Core, MudTheme fixes
- Auth: AssignmentsController auth bug, ReleaseCamera result, logout endpoint
- Security: open redirect fix
- Workers: AgentState thread-safety, CameraStreamService async, HttpClientFactory
- EF Core: AddCameraDiscoveryFields migration, DI interceptors, retry helper
- UI: MudTheme palette config, aria-labels on icon buttons
2026-07-19 19:58:45 +00:00
Arnaud Dartois d9f5224e21 fix: resolve review findings — SignalR JWT, enum serialization, TCS leak, thread safety 2026-07-19 15:54:13 +00:00
Arnaud Dartois 926d866749 fix(security): validate returnUrl against open redirect
The returnUrl query parameter is now validated as a local/relative URL
(starts with '/' and does not contain '://') before being used as a
redirect target after login.
2026-07-19 15:54:07 +00:00
Arnaud Dartois 54496cd947 refactor: extract duplicate JS interop signIn to AuthHelper
Both Login and Register pages had identical JsRuntime.InvokeVoidAsync calls
with the same anonymous object shape. Extracted to a shared AuthHelper
static class with SignInAsync(IJSRuntime, object) and CreateSignInPayload(UserInfo).

- New file: Services/AuthHelper.cs
- Login.razor and Register.razor now call AuthHelper.SignInAsync
- Pre-existing fix: Person.cs IAuditableEntity setters made public
2026-07-19 15:53:38 +00:00
Arnaud Dartois 0030173c38 refactor: rename mud-button-submit to auth-submit-btn
Avoid potential CSS conflicts with future MudBlazor versions using a
project-specific class name for auth page submit buttons.
2026-07-19 15:50:32 +00:00
Arnaud Dartois 70176124cb refactor(css): merge duplicate dark mode media blocks into one
- Single @media (prefers-color-scheme: dark) block containing both
  auth-specific rules and general (body, blazor-error-ui) rules
- Removes duplicate @media query, simplifies maintenance
2026-07-19 15:49:46 +00:00
Arnaud Dartois 898a9be6fa fix: remove method="post" from Blazor interactive forms 2026-07-19 15:49:00 +00:00
Arnaud Dartois 493747bb70 feat(ui): add global search bar in header with smart routing 2026-07-19 15:35:44 +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 0d2f0574c9 feat(ui): add snapshot gallery with lightbox and search filter 2026-07-19 15:19:33 +00:00
Arnaud Dartois 2d65f273c6 feat(ui): enrich dashboard with event data, camera status, and agent workload 2026-07-19 13:30:03 +00:00
Arnaud Dartois add9ebf462 feat(ui): add events page and event timeline on camera detail 2026-07-19 13:21:25 +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 9113191547 feat(ui): modernize all pages — auto-refresh, skeleton loading, tooltips, filters 2026-07-19 07:12:40 +00:00
Arnaud Dartois 2ff355e567 feat(auth): add default groups, claims-based authorization and update spec 2026-07-19 07:04:25 +00:00
Arnaud Dartois 57b51f403c feat(web): add profile, roles, groups and claims pages 2026-07-19 06:49:17 +00:00
Arnaud Dartois 3056452b9e fix(web): repair design on users page, settings page and audit logs 2026-07-19 06:34:32 +00:00
Arnaud Dartois ca693a2ed0 fix(web): repair home page design — invalid CSS, dead code, missing form wrappers 2026-07-19 06:28:13 +00:00
Arnaud Dartois 39f08e39ed fix(web): add cookie authentication to fix IAuthenticationService missing error 2026-07-18 20:59:38 +00:00
Arnaud Dartois cca6ab6f46 feat(mvp): agent settings UI + migration orchestrator
Agent settings UI:
- Add settings section to AgentDetail page showing per-agent overrides
- Add/edit/delete agent settings with confirmation dialogs
- Add settings API methods + DTOs to HeimdallApiClient
- Real-time SignalR notification shown in UI feedback

Migration orchestrator:
- Replace inline db.Database.Migrate() with MigrationHostedService
- Runs migrations in background at startup (non-blocking)
- 60-second timeout with critical logging on failure
- Preserves Testing environment exclusion
- Clear migration progress logging
2026-07-18 19:07:01 +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 12a1ff2737 fix(ui): implement token generation in SitesPage.CopyToken
Replaces the no-op CopyToken method with actual API call.
Adds a dialog showing the generated token with expiry warning.
2026-07-17 20:04:52 +00:00
Arnaud Dartois 20e2a235ad chore: remove stale NavMenu.razor template boilerplate
NavMenu.razor contained Counter/Weather links from the default Blazor
template and was never used (MainLayout.razor has its own navigation).
Removed the associated scoped CSS file to fix BLAZOR102 build error.
2026-07-17 19:26:27 +00:00
Arnaud Dartois 8c7ec4d279 feat(ui): pages détail Caméra + Agent
- CameraDetail: vue modifiable (nom, RTSP), infos fabricant/modèle/statut
- AgentDetail: infos hostname/version/heartbeat + capacités CPU/GPU/mémoire
- CamerasPage: nom cliquable vers le détail
- AgentsPage: nom cliquable vers le détail
- ApiClient: GetCameraAsync, UpdateCameraAsync, GetAgentAsync
2026-07-17 19:08:17 +00:00
Arnaud Dartois b816446f72 feat(audit): journal d'audit consultable dans l'UI
- IAuditLogService + AuditLogService avec pagination et filtres
- AuditLogsController: GET /api/audit-logs (resourceType, action, page)
- AuditLogsPage Blazor: liste paginée avec filtres + coloration par action
- Lien vers le journal dans le menu Admin (visible pour les Admins)
2026-07-17 18:14:41 +00:00
Arnaud Dartois c6450ad50d feat(api): dedicated /api/stats endpoint
- StatsController: aggregates sites, cameras, agents counts in one DB query
- Dashboard: now uses stats endpoint (2 API calls instead of N*2+1)
- ApiClient: GetStatsAsync + StatsResult DTO
2026-07-17 17:22:33 +00:00
Arnaud Dartois 1fd3f8f003 feat(dashboard): real stats with parallel API calls
- Dashboard now shows: total sites, total cameras, online agents, active sites
- Stats loaded in parallel with Task.WhenAll for performance
- Falls back gracefully if cameras/agents endpoints return no data
2026-07-17 15:10:14 +00:00
Arnaud Dartois 3be0993fb5 feat(ui): multi-role selection with checkboxes
- Users: replace single MudSelect role picker with MudCheckBox multi-select
- Users: users can now have multiple roles (Admin + Supervisor, etc.)
- Users: edit dialog validates at least one role is selected
- Build: suppress MudBlazor analyzer MUD0002 (false positive on Checked bind)
2026-07-17 13:26:15 +00:00
Arnaud Dartois cb855f83b8 feat(ui): login redirect + configurable API URL
- Login: redirect to original page after auth via returnUrl query param
- RedirectToLogin: encodes current URL as ?returnUrl=/path
- API URL: configurable via appsettings.json ApiBaseUrl or API_BASE_URL env
- NotFound page: preserved from template
2026-07-17 13:22:02 +00:00
Arnaud Dartois da123ec544 fix(tests): InMemory DB isolation + refactor test helpers
- Fix: InMemory database name now unique per test factory instance
  (was using process-wide env var, now per-host config via UseSetting)
- Refactor: all integration tests use shared TestHelpers.CreateAdminClientAsync
- New: register-admin endpoint (test/dev only) creates Admin users directly
- New: TestHelpers.cs with extension method for admin client creation
- Cleanup: removed bootstrap template files, old Counter/Weather pages
- Cleanup: simplified app.css with MudBlazor-only styles
- Seed: demo admin + demo site created in Development mode
2026-07-17 13:15:25 +00:00
Arnaud Dartois 129bcfa9d7 feat(ui): Blazor auth redirect + CascadingAuthenticationState
- Routes: wrap with CascadingAuthenticationState + AuthorizeRouteView
- RedirectToLogin: component that redirects unauthenticated users to /login
- HeimdallAuthStateProvider: NotifyLogin/NotifyLogout methods
- Login/Register/MainLayout: use AuthStateProvider.NotifyLogin/Logout
  instead of direct AuthState mutation (triggers Blazor auth cascade)
- _Imports: add Microsoft.AspNetCore.Components.Authorization
2026-07-17 07:05:07 +00:00
Arnaud Dartois d4a86b8c7f feat(mvp): docker-compose snippet in UI, agent flow tests
- Site detail: generate registration token with copy/paste docker-compose snippet
- Docker snippet: pre-filled with token + agent hostname, ready to copy
- Agents integration tests: register with valid token, heartbeat with API key,
  invalid token rejection (3 new tests)
- TokenResult DTO for API client
- IJSRuntime clipboard copy for docker-compose snippet
2026-07-17 07:00:58 +00:00
Arnaud Dartois 2ea82504d7 feat(mvp): rate limiting, agents page, site detail navigation
- Rate limiting: Microsoft.AspNetCore.RateLimiting AddFixedWindowLimiter
  (Auth: 10 req/min, Api: 200 req/min, returns 429 when exceeded)
- Agents Blazor: new page listing agents per site with status/heartbeat
- Site detail: camera and agent navigation cards
- ApiClient: GetAgentsBySiteAsync, AgentItem DTO
- Removed custom middleware (replaced by proper built-in rate limiter)
2026-07-17 06:57:00 +00:00
Arnaud Dartois dfc888db94 feat(mvp): agent auth, cameras UI, rate limiting attempt
- Agent: fix heartbeat auth — set API Key header after registration
- Cameras Blazor: full page with create/delete/list by site
- ApiClient: cameras CRUD endpoints + CameraItem DTO
- Rate limiting: attempted but deferred (System.Threading.RateLimiting package issue)
- Security: refresh token rotation now enforced server-side
2026-07-17 06:30:09 +00:00
Arnaud Dartois 38816aec8a feat(mvp): complete Blazor UI + User Management + integration tests 2026-07-16 21:19:16 +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