- 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
Move ConfigureApplicationCookie configuration from DependencyInjection.cs
to Program.cs, ensuring it's called AFTER AddAuthentication().AddCookie().
This prevents Identity default paths (/Account/Login) from overriding
custom login paths (/login).
Add ConfigureApplicationCookie to override Identity default paths
(/Account/Login) with custom paths (/login). This fixes the 404 error
when unauthenticated users are redirected to the login page.
DbContext is not thread-safe for concurrent operations. Running multiple
queries in parallel with Task.WhenAll caused 'A second operation was
started on this context instance before a previous operation completed'
exceptions, resulting in 500 errors on the stats endpoint.
The application forced HTTPS redirection and secure cookies
even in HTTP-only mode (Docker deployment), preventing
plain HTTP connections.
Make UseHttpsRedirection() conditional on ASPNETCORE_URLS
and change CookieSecurePolicy from Always to SameAsRequest.
- Revert ServiceResult to protected set + protected constructors
- Remove new() constraint from ValidationBehavior
- Use static Failure() factory method via reflection instead
- 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)
- Supprime InMemory de tous les .csproj (Infrastructure, Domain.Tests, IntegrationTests)\n- Supprime le branchement Database:Provider=InMemory de DependencyInjection.cs\n (plus que du PostgreSQL natif)\n- Infrastructure.Tests: CameraAssignment + CameraEvent tests -> Testcontainers\n- PostgreSqlContainerFixture ajoute aux Infrastructure.Tests\n- appsettings.Testing.json: retire Database:Provider et Hangfire:Enabled\n- 4 tests echouent encore: bugs pre-existants masques par InMemory\n (FK non respectees, donnees de test erronees)\n\nTests: 222/226 passed (4 pre-existants lies aux FK)
- Ajout isTesting = builder.Environment.IsEnvironment("Testing")\n Les tests WebApplicationFactory n'ont pas de PostgreSQL\n- Hangfire DI + recurring jobs skips si isTesting\n- Compatible avec appsettings.Testing.json (Hangfire:Enabled=false retire)\n\nFix le CI qui plantait: 'Failed to connect to 127.0.0.1:5432'\nTests: 226/226 passed
- Hangfire: retire le flag Hangfire:Enabled (toujours actif si DATABASE_URL\n est defini, skip automatiquement en test sans config)\n- Database:MigrateOnStartup: default true en Production (.IsProduction())\n Plus besoin de variable d'env pour que les migrations s'executent\n- Recurring jobs registers dans if(connectionString) pour eviter le\n crash 'No service for IRecurringJobManager' quand Hangfire est skip\n- Corrige le crash boucle 'relation roles does not exist' apres reset DB\n\nBuild: 0 errors, 0 warnings\nTests: 226/226 passed
- Database:MigrateOnStartup default now true in Production\n (GetValue<bool?> null-coalesce app.Environment.IsProduction())\n Evite le crash 'relation roles does not exist' apres reset DB\n- En Testing: reste false (comportement inchange)
HealthController already exposes [HttpGet("/healthz")]
and [HttpGet("/readyz")]. The duplicate MapGet in Program.cs
caused AmbiguousMatchException on every /healthz request.
UseStatusCodePagesWithReExecute('/not-found') intercepts all 4xx
responses and re-executes the pipeline as POST /not-found.
Since /not-found is a Blazor component requiring antiforgery, the
re-executed POST would fail with 400 (no CSRF token).
API controllers now return proper 401/403 for unauthenticated
requests. All 61 integration tests pass.
UseAntiforgery() was before UseAuthentication(), causing all POST
requests to API controllers to get 400 (missing CSRF token) before
auth could return 401. Moving it after authorization ensures:
1. Auth middleware runs first → unauthenticated requests get 401
2. Antiforgery middleware validates tokens only for requests
that pass auth (Blazor components)
3. API controllers and SignalR hubs work without CSRF tokens
Roles (Admin, Viewer, etc.) must exist before any user registration
attempts to add a user to a role. The seeding was only in the old
Heimdall.Api/Program.cs — moved to Web/Program.cs and runs in ALL
environments (not skipped in Testing).
Now 54/61 integration tests pass (was 6/61). Remaining 7 failures
are all 'expected 401 got 400' — pre-existing auth middleware
difference.
- Add InternalsVisibleTo for Heimdall.Api.Tests and
Heimdall.IntegrationTests in Web.csproj
- Add partial class Program for WebApplicationFactory<Program>
- Pass builder.Environment.EnvironmentName instead of env var
so AddInfrastructure correctly detects Testing environment
- Skip DATABASE_URL check, Hangfire setup, migrations, and
recurring jobs when environment is Testing
- Update test project references from Heimdall.Api to 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
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.
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.
- 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
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
- 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
The self-signed certificate auto-bootstrap for DataProtection key
encryption ran unconditionally, causing integration tests to crash
with CryptographicException (m_safeCertContext is an invalid handle)
when Identity token providers tried to use the certificate encryptor.
The test environment has no /var/lib/heimdall/dp-keys/ directory, and
loading a PFX with empty password is fragile on Linux — the X509
certificate handle becomes invalid.
Wrap the certificate + file persistence code in the same if (isTesting)
guard already used for the DbContext setup. Tests now use ephemeral
DataProtection keys without certificate encryption.
Generates a self-signed X.509 certificate on first run and stores it
alongside DP keys in the persistent volume. Uses ProtectKeysWithCertificate
to encrypt data protection keys at rest. Prevents the 'No XML encryptor
configured' startup warning.
Adds ValueComparer<float[]> with element-by-element comparison and
snapshot copy. Prevents EF Core warning 10620 about collection types
with value converters but no value comparer.
Adds HasQueryFilter for CameraAssignment (→Agent), CameraDiscoveryResult
(→Site), and CameraEvent (→Camera) to match existing pattern.
Prevents EF Core warning 10622 about required ends with global query
filters.
The TimeZoneNotFoundException catch was unconditionally accepting all
values, which made timezone validation a no-op on systems WITH tzdata.
Restore the lazy _hasTzData detection: when tzdata is available, reject
invalid IANA timezone ids; when tzdata is missing, accept all values.
Fixes InvalidTimezone_FailsValidation test.
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.