fix: resolve demo admin seeding, Sentry DSN pass-through, and add startup diagnostics
- Replace IsDevelopment() guard with Seed:DemoOnStartup config flag (default: true, disable via SEED__DEMO_ON_STARTUP=false) - Add Seed:AdminLogin (env SEED__ADMIN_LOGIN) to customize demo admin email - Add Seed:AdminDisplayName (env SEED__ADMIN_DISPLAYNAME) to customize display name - Add Sentry__Dsn env var to docker-compose files (matches .env convention) - Increase Heimdall log level to Debug for startup diagnostics - Add [DIAG] startup logs for Sentry DSN, Data Protection keys, environment - Add Data Protection key directory diagnostic in DependencyInjection
This commit is contained in:
1 parent
100e230af5
commit
afc1b2e032
7 files changed
+579
-7
No files matched your search
@@ -138,20 +138,21 @@ using (var seedScope = app.Services.CreateScope())
|
||||
await groupDb.SaveChangesWithRetryAsync();
|
||||
|
||||
// Seed demo admin + demo site in Development only
|
||||
if (app.Environment.IsDevelopment())
|
||||
if (builder.Configuration.GetValue<bool>("Seed:DemoOnStartup", true))
|
||||
{
|
||||
var testAdmin = await userManager.FindByEmailAsync("admin@heimdall.test");
|
||||
var adminLogin = builder.Configuration.GetValue<string>("Seed:AdminLogin") ?? Environment.GetEnvironmentVariable("SEED__ADMIN_LOGIN") ?? "admin@heimdall.test";
|
||||
var testAdmin = await userManager.FindByEmailAsync(adminLogin);
|
||||
if (testAdmin is null)
|
||||
{
|
||||
testAdmin = new Heimdall.Domain.Entities.AppUser
|
||||
{
|
||||
UserName = "admin@heimdall.test",
|
||||
Email = "admin@heimdall.test",
|
||||
DisplayName = "Admin"
|
||||
UserName = adminLogin,
|
||||
Email = adminLogin,
|
||||
DisplayName = builder.Configuration.GetValue<string>("Seed:AdminDisplayName") ?? Environment.GetEnvironmentVariable("SEED__ADMIN_DISPLAYNAME") ?? "Admin"
|
||||
};
|
||||
var adminPassword = builder.Configuration["Seed:AdminPassword"]
|
||||
?? Environment.GetEnvironmentVariable("SEED__ADMIN_PASSWORD")
|
||||
?? throw new InvalidOperationException("Seed:AdminPassword is required in config or SEED__ADMIN_PASSWORD env var. This is only needed for Development seeding.");
|
||||
?? throw new InvalidOperationException("Seed:AdminPassword is required in config or SEED__ADMIN_PASSWORD env var. Set this env var to create the demo admin on startup.");
|
||||
await userManager.CreateAsync(testAdmin, adminPassword);
|
||||
await userManager.AddToRoleAsync(testAdmin, AppRoles.Admin);
|
||||
}
|
||||
@@ -291,6 +292,16 @@ public partial class Program {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// ── Startup diagnostics ────────────────────────────────────────
|
||||
var sentryStatus = string.IsNullOrEmpty(sentryDsn)
|
||||
? "NOT CONFIGURED — errors will NOT be reported to GlitchTip"
|
||||
: "configured (" + sentryDsn[..sentryDsn.IndexOf('@')] + "@...)";
|
||||
Console.WriteLine($"[DIAG] Sentry/GlitchTip DSN: {sentryStatus}");
|
||||
Console.WriteLine($"[DIAG] Environment: {builder.Environment.EnvironmentName}");
|
||||
Console.WriteLine($"[DIAG] Data Protection keys dir: /var/lib/heimdall/dp-keys");
|
||||
Console.WriteLine($"[DIAG] Demo seeding: {(builder.Configuration.GetValue<bool>("Seed:DemoOnStartup", true) ? "enabled (set Seed:DemoOnStartup=false to disable)" : "disabled")}");
|
||||
|
||||
builder.Services.AddRazorComponents()
|
||||
.AddInteractiveServerComponents();
|
||||
|
||||
|
||||
Reference in new issue
Block a user