Commit Graph
18 Commits
Author SHA1 Message Date
Arnaud Dartois d9a3ea52ba refactor: remove Heimdall.Api, move all routes into Heimdall.Web
Heimdall.Api controllers/hubs/filters were exact duplicates of
files already in Heimdall.Web (same namespace, same content).
The Api project was a leftover from before the single-image merge.

Changes:
- Add missing registrations to Web/Program.cs (JWT Bearer auth,
  rate limiting, controllers with ExceptionFilter, FluentValidation,
  SignalR + broadcast services, OpenAPI/Scalar, CORS, hub mappings)
- Add FluentValidation.AspNetCore, Scalar.AspNetCore,
  Microsoft.AspNetCore.OpenApi NuGet packages to Web.csproj
- Remove Heimdall.Api from solution and delete the project
- All routes continue working at their existing paths
2026-07-20 20:22:30 +00:00
Arnaud Dartois 8ac088de38 fix(web): use port 8080 as default API_BASE_URL for Docker compat
The HeimdallApiClient calls the API via HTTP on localhost.
Inside Docker, the app listens on port 8080 (ASPNETCORE_URLS),
but the default was 5000 (host-mapped port) — causing connection
refused on all API calls from Blazor Server UI.

Fix: change default from localhost:5000 to localhost:8080.
2026-07-20 20:09:24 +00:00
Arnaud Dartois 34037c20bf fix(dp): keep X509Certificate2 alive for DataProtection key ring
- Remove `using var` from dpCert so the cert stays alive for
  ProtectKeysWithCertificate (was disposed, causing
  CryptographicException)
- Add query filter on DiscoveredStreamUrl for model warning #10622
- Simplify migration retry: call Migrate() directly instead of
  GetPendingMigrations()+Migrate() to reduce transient startup noise
2026-07-20 19:58:32 +00:00
Arnaud Dartois 630e7987fe refactor(docker): merge worker and web into single heimdall image
Combine Heimdall.Web and Heimdall.Workers into one process/image.
Hangfire background jobs now run inside the web process.

- Move job classes to Infrastructure/Jobs/ (no Worker SDK dependency)
- Add Hangfire server + recurring jobs to Web/Program.cs
- Add missing AddInfrastructure/AddApplication DI registrations to Web
- Rename image: heimdall (was heimdall-web / heimdall-workers)
- Remove src/Heimdall.Workers project entirely
- Remove tests/Heimdall.Workers.Tests (placeholder)
- Simplify Dockerfile: single build target, no workers publish
- Update docker-compose files: one service heimdall, no workers
- Update Makefile, .env.example
2026-07-20 17:22:56 +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 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 ba968a5f23 fix(security): harden Docker, CSRF, EventsHub scoping, secret logging, tests
- Docker: remove default passwords from prod compose (required env vars)
- CSRF: validate antiforgery tokens on /_auth/signin and /_auth/signout
- EventsHub: broadcast to site-scoped Group() instead of Clients.All
- SettingsController: redact secret values in logs
- Create SetAgentSettingValidator + UpdateAppSettingValidator classes
- Replace 3 placeholder test projects with meaningful tests
- Remove FluentValidation auto-validation (incompatible with .NET 10)
2026-07-19 20:53:48 +00:00
Arnaud Dartois 32025eae67 fix(infra): persist Data Protection keys to filesystem for Docker
- Add PersistKeysToFileSystem to /var/lib/heimdall/dp-keys so camera
  credential decryption survives container restarts
- Remove hardcoded connection string fallback, throw instead
- Add Microsoft.AspNetCore.DataProtection.Extensions dependency
2026-07-19 19:33:10 +00:00
Arnaud Dartois d2288617f7 fix(web): replace MapStaticAssets with UseStaticFiles 2026-07-19 18:37:52 +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 8c6b2610a0 fix(web): register HeimdallAuthStateProvider concrete type in DI
The service was registered only as AuthenticationStateProvider (base class),
but Login.razor, Register.razor, and MainLayout.razor inject the concrete
@inject HeimdallAuthStateProvider. Blazor's DI could not resolve it,
causing InvalidOperationException on page render.

Fix: register the concrete type first, then make the base class
registration resolve to the same instance via GetRequiredService.
2026-07-18 21:08:08 +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 fdfd506977 fix: resolve GlitchTip anomalies — DB retry, query filters, Sentry DSN, Workers tracking
- 🔴 Fix startup crash when DB is temporarily unavailable: add 5x retry
  with exponential backoff to Database.MigrateAsync() in API and Workers
- 🔴 Fix EF Core 'required navigation with query filter' warnings:
  add matching soft-delete query filters to AgentSetting, CameraCredentials,
  CameraDetectionProfile, UserSite
- 🔴 Add Sentry error tracking to Workers (Hangfire background jobs)
- 🟡 Make Sentry/GlitchTip DSN configurable via SENTRY_DSN env var
  (applies to API, Web, Agent, Workers)
- 🟡 Suppress EF Core RedundantIndexRemoved informational messages

Closes GlitchTip #538
2026-07-18 20:31:37 +00:00
Arnaud Dartois cc52214404 feat: add Sentry (GlitchTip) client to Api, Agent, Web
Add Sentry.AspNetCore v6.7.0 with hardcoded DSN constant
(not overridable by env) pointing to GlitchTip instance at
https://glitchtip.tordais.cc/6.

Same DSN configured across all three entry-point projects:
- Heimdall.Api
- Heimdall.Agent
- Heimdall.Web
2026-07-18 19:41:57 +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 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 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