- 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
- Heimdall.Web/Program.cs: use Sentry:Dsn from IConfiguration as primary
source with legacy SENTRY_DSN env var as fallback (no hardcoded DSN)
- Heimdall.Agent/Program.cs: same pattern applied
- Both: add MaxRequestBodySize=Small and ProfilesSampleRate=0.05
(previously missing); lower TracesSampleRate to 0.05
- appsettings.json: add Sentry:Dsn entry for discoverability
Resolves codify signal: hardcoded-sdk-credentials (C1)
Replace new Uri(url.TrimEnd('/') + "/") pattern with explicit
EndsWith('/') check to avoid string concatenation inside URI
construction. Applies to 3 locations:
- Program.cs (Heimdall.Web) - HttpClient base address
- TokenRefreshHandler.cs - raw HttpClient for token refresh
- Program.cs (Heimdall.Agent) - Central service client
Replace the 'Admin123!Pass' fallback with an InvalidOperationException
that requires Seed:AdminPassword from config or SEED__ADMIN_PASSWORD env
variable. Keeps the env var fallback as second option before throwing.
- 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).
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.
- 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
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 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.
- 🔴 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
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
- 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