From 021bdecab35ff9ebc9ce555294ecbe67d09ef7d1 Mon Sep 17 00:00:00 2001 From: Arnaud Dartois Date: Fri, 13 Nov 2026 10:38:44 +0100 Subject: [PATCH] docs: align Hangfire dashboard guide with route (#370) Co-authored-by: Arnaud Dartois --- docs/hangfire-usage.md | 27 ++++++++++----------------- skills/hangfire-startup-lock/SKILL.md | 2 ++ 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/docs/hangfire-usage.md b/docs/hangfire-usage.md index 21a2e57..c03b5e2 100644 --- a/docs/hangfire-usage.md +++ b/docs/hangfire-usage.md @@ -15,7 +15,7 @@ │ │ │ Hangfire Server │ │ ├── Storage: PostgreSQL (Hangfire.PostgreSql) │ -│ ├── Dashboard: /admin/jobs (authentifié, Admin only) │ +│ ├── Dashboard: /hangfire (AdminJobs ou rôle Admin) │ │ └── Jobs: │ │ ├── RetentionCheck (Recurring, daily) │ │ ├── S3Cleanup (Recurring, daily) │ @@ -467,27 +467,20 @@ public class HangfireInitializer : IHostedService Intégré à l'UI Admin, authentifié, pas exposé publiquement : +La route Central est mappée par `MapHangfireDashboard("/hangfire", ...)` dans +`src/Heimdall.Web/Program.cs`. `HangfireAdminAuthorizationFilter` autorise les +requêtes authentifiées portant `Admin.Jobs` ou le rôle `Admin`. Le dashboard +n'est pas mappé dans l'environnement `Testing`. + ```csharp -// Heimdall.Api / Program.cs -app.UseHangfireDashboard("/admin/jobs", new DashboardOptions +// Heimdall.Web/Program.cs +app.MapHangfireDashboard("/hangfire", new DashboardOptions { Authorization = [ - new HangfireAuthorizationFilter() // vérifie AppPermissions.AdminJobs + new HangfireAdminAuthorizationFilter() ], - StatsPollingInterval = 3000, // 3s - DisplayStorageConnectionString = false, - DashboardTitle = "Heimdall — Jobs", }); - -public class HangfireAuthorizationFilter : IDashboardAuthorizationFilter -{ - public bool Authorize(DashboardContext context) - { - var httpContext = context.GetHttpContext(); - return httpContext.User?.IsInRole(AppRoles.Admin) == true; - } -} ``` --- @@ -529,4 +522,4 @@ Hangfire dashboard is accessible only to Admin Hangfire dashboard returns 403 for non-Admin Agent jobs are recreated after agent restart Agent InMemory storage does not persist across restarts -``` \ No newline at end of file +``` diff --git a/skills/hangfire-startup-lock/SKILL.md b/skills/hangfire-startup-lock/SKILL.md index 8404add..5acf502 100644 --- a/skills/hangfire-startup-lock/SKILL.md +++ b/skills/hangfire-startup-lock/SKILL.md @@ -7,6 +7,8 @@ description: Diagnose and recover Heimdall startup from transient Hangfire Postg Heimdall registers all recurring jobs synchronously after database migrations in `src/Heimdall.Web/Program.cs`. Hangfire's PostgreSQL storage acquires a distributed lock per recurring-job id during `AddOrUpdate`; `agent-failover` is currently the first registration after removing the legacy `heartbeat-monitor` id. +The Central dashboard route is mapped from the same Program.cs with `MapHangfireDashboard("/hangfire", ...)`, guarded by `HangfireAdminAuthorizationFilter` for `Admin.Jobs` or the Admin role, and omitted in `Testing`. When updating `docs/hangfire-usage.md`, verify the route and filter against these sources; do not copy a stale `UseHangfireDashboard` or `/admin/jobs` example. + ## Implementation and diagnosis - Inspect the GlitchTip event stack, app start time, event timestamps, and `Program.cs`/`JobSetup.cs` line references. A timeout names the contended job key; it proves lock contention, not the number or identity of competing processes.