diff --git a/.env.example b/.env.example
index 96b1588..69f0d34 100644
--- a/.env.example
+++ b/.env.example
@@ -14,7 +14,6 @@
POSTGRES_PASSWORD=heimdall
DATABASE_URL=Host=postgresql;Port=5432;Database=heimdall;Username=heimdall;Password=heimdall
# Set SERVER_IMAGE_REFERENCE from docker/server-image.json before production deployment.
-UPDATES_RELEASE_API_URL=https://sources.tordais.cc/api/v1/repos/arnaud.dartois/Heimdall/releases/latest
# JWT (change in production!)
# JWT__Key is used for access tokens, JWT__RefreshKey for refresh tokens.
@@ -54,26 +53,12 @@ HEIMDALL_AGENT_NAME=agent-01
HEIMDALL_HEARTBEAT_INTERVAL=30
HEIMDALL_REGISTRATION_RETRIES=5
-# Email (SMTP) — notifications
-EMAIL__SMTP_HOST=smtp.example.com
-EMAIL__SMTP_PORT=587
-EMAIL__USERNAME=
-EMAIL__PASSWORD=
-EMAIL__FROM_ADDRESS=noreply@heimdall.local
-EMAIL__FROM_NAME=Heimdall
-EMAIL__USE_SSL=true
-
-# ntfy push notifications
-NTFY__BASE_URL=http://ntfy:80
-NTFY__TOKEN=
-
# Coturn (TURN relay for WebRTC)
COTURN_SECRET=ChangeMeAtLeast32BytesLongCoturnSecret!
COTURN_REALM=heimdall.local
# Ollama (local LLM for daily summaries)
OLLAMA_PORT=11434
-OLLAMA_URL=
# Redis (SignalR backplane, optional — scaling)
REDIS_PORT=6379
diff --git a/docker/docker-compose.ollama.yml b/docker/docker-compose.ollama.yml
index 41a81b2..765eb6d 100644
--- a/docker/docker-compose.ollama.yml
+++ b/docker/docker-compose.ollama.yml
@@ -1,4 +1,4 @@
-# Optional local Ollama backend. Set OLLAMA_URL=http://ollama:11434 on Central.
+# Optional local Ollama backend. Configure http://ollama:11434 in Central settings.
services:
ollama:
image: ollama/ollama:latest
diff --git a/docker/docker-compose.prod.yml b/docker/docker-compose.prod.yml
index 9e1a559..0afe1bf 100644
--- a/docker/docker-compose.prod.yml
+++ b/docker/docker-compose.prod.yml
@@ -43,23 +43,9 @@ services:
ASPNETCORE_ENVIRONMENT: ${ASPNETCORE_ENVIRONMENT:-Production}
ASPNETCORE_URLS: http://+:8080
Cors__AllowedOrigins: ${Cors__AllowedOrigins:-*}
- API_BASE_URL: ${API_BASE_URL:-http://localhost:8080}
- Updates__ReleaseApiUrl: ${UPDATES_RELEASE_API_URL:?Set the Central release API URL}
Sentry__Dsn: ${SENTRY_DSN:-}
Sentry__TracesSampleRate: ${SENTRY_TRACES_SAMPLE_RATE:-0.05}
Sentry__Release: ${SENTRY_RELEASE:-}
- EMAIL__SMTP_HOST: ${EMAIL__SMTP_HOST:-}
- EMAIL__SMTP_PORT: ${EMAIL__SMTP_PORT:-587}
- EMAIL__USERNAME: ${EMAIL__USERNAME:-}
- EMAIL__PASSWORD: ${EMAIL__PASSWORD:-}
- EMAIL__FROM_ADDRESS: ${EMAIL__FROM_ADDRESS:-noreply@heimdall.local}
- EMAIL__FROM_NAME: ${EMAIL__FROM_NAME:-Heimdall}
- EMAIL__USE_SSL: ${EMAIL__USE_SSL:-true}
- # Optional integrations are configured only when their service is deployed.
- OLLAMA_URL: ${OLLAMA_URL:-}
- NTFY__BASE_URL: ${NTFY__BASE_URL:-http://ntfy:80}
- NTFY__TOKEN: ${NTFY__TOKEN:-}
- STORAGE__PROVIDER: ${STORAGE__PROVIDER:-Local}
ports:
- "${WEB_PORT:-5000}:8080"
volumes:
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 04dd74b..eee5b0a 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -36,17 +36,6 @@ services:
ASPNETCORE_ENVIRONMENT: ${ASPNETCORE_ENVIRONMENT:-Development}
ASPNETCORE_URLS: http://+:8080
Cors__AllowedOrigins: ${Cors__AllowedOrigins:-*}
- API_BASE_URL: ${API_BASE_URL:-http://localhost:8080}
- OLLAMA_URL: ${OLLAMA_URL:-}
- NTFY__BASE_URL: ${NTFY__BASE_URL:-http://ntfy:80}
- NTFY__TOKEN: ${NTFY__TOKEN:-}
- EMAIL__SMTP_HOST: ${EMAIL__SMTP_HOST:-}
- EMAIL__SMTP_PORT: ${EMAIL__SMTP_PORT:-587}
- EMAIL__USERNAME: ${EMAIL__USERNAME:-}
- EMAIL__PASSWORD: ${EMAIL__PASSWORD:-}
- EMAIL__FROM_ADDRESS: ${EMAIL__FROM_ADDRESS:-noreply@heimdall.local}
- EMAIL__FROM_NAME: ${EMAIL__FROM_NAME:-Heimdall}
- EMAIL__USE_SSL: ${EMAIL__USE_SSL:-true}
ports:
- "${WEB_PORT:-5000}:8080"
volumes:
diff --git a/docs/docker-compose.md b/docs/docker-compose.md
index f167e3b..23867bd 100644
--- a/docs/docker-compose.md
+++ b/docs/docker-compose.md
@@ -15,8 +15,8 @@ The database password in `DATABASE_URL` must match `docker/secrets/db_password`.
mkdir -p -m 700 docker/secrets
openssl rand -base64 32 > docker/secrets/db_password
cp .env.example docker/.env
-# Set DATABASE_URL, JWT__KEY, JWT__REFRESHKEY, SERVER_IMAGE_REFERENCE,
-# and UPDATES_RELEASE_API_URL in docker/.env.
+# Set DATABASE_URL, JWT__KEY, JWT__REFRESHKEY and SERVER_IMAGE_REFERENCE
+# in docker/.env. Configure integrations and the release API in Central's UI.
docker compose --env-file docker/.env -f docker/docker-compose.prod.yml up -d
```
@@ -65,10 +65,10 @@ docker compose --env-file docker/.env -f docker/docker-compose.redis.yml up -d
docker compose --env-file docker/.env -f docker/docker-compose.backup.yml up -d
```
-Configure Ollama with `OLLAMA_URL=http://ollama:11434` when enabled. Choose
-RustFS as the storage provider in Central and use `http://rustfs:9000` as its
-endpoint. ntfy defaults to `http://ntfy:80`; the UI can also be configured to
-use an external ntfy server. TURN is not required until WebRTC is enabled.
+Configure Ollama at `http://ollama:11434` in Central's AI settings when enabled.
+Choose RustFS as the storage provider in Central and use `http://rustfs:9000` as
+its endpoint. Configure the ntfy server URL in Central's notification settings.
+TURN is not required until WebRTC is enabled.
Redis is provided as a standalone service but is not currently required by
Central. Backups are independent of the core startup and require the core
network and PostgreSQL service to be running.
diff --git a/readme.md b/readme.md
index 97c58f2..dc3570b 100644
--- a/readme.md
+++ b/readme.md
@@ -217,10 +217,8 @@ Générer un token via `POST /api/sites/{id}/tokens` sur l'API.
## Authentification
-La source des mises à jour est configurée côté Central par `Updates:ReleaseApiUrl`
-(`UPDATES_RELEASE_API_URL` dans le Compose de production, ou
-`Updates__ReleaseApiUrl` directement). Cette valeur est requise au déploiement
-et peut être changée sans recompiler le serveur. L'agent lit le nom et le digest
+La source des mises à jour se configure dans les paramètres globaux de Central.
+L'agent lit le nom et le digest
de l'image dans le manifeste authentifié de Central ; le dépôt d'image Agent est
défini dans `docker/agent-image.json` et celui du serveur dans
`docker/server-image.json`.
diff --git a/scripts/ci/validate-compose.sh b/scripts/ci/validate-compose.sh
index 27251d0..474c3db 100755
--- a/scripts/ci/validate-compose.sh
+++ b/scripts/ci/validate-compose.sh
@@ -31,7 +31,7 @@ for required in DATABASE_URL POSTGRES_PASSWORD JWT__KEY JWT__REFRESHKEY; do
fi
done
-for required in SERVER_IMAGE_REFERENCE DATABASE_URL JWT__KEY JWT__REFRESHKEY UPDATES_RELEASE_API_URL; do
+for required in SERVER_IMAGE_REFERENCE DATABASE_URL JWT__KEY JWT__REFRESHKEY; do
if env "$required=" docker compose \
--env-file .env.example -f docker/docker-compose.prod.yml config --quiet >/dev/null 2>&1; then
echo "Production Compose accepted missing required variable: $required" >&2
@@ -39,6 +39,13 @@ for required in SERVER_IMAGE_REFERENCE DATABASE_URL JWT__KEY JWT__REFRESHKEY UPD
fi
done
+for forbidden in API_BASE_URL UPDATES_RELEASE_API_URL EMAIL__SMTP_HOST EMAIL__SMTP_PORT EMAIL__USERNAME EMAIL__PASSWORD EMAIL__FROM_ADDRESS EMAIL__FROM_NAME EMAIL__USE_SSL OLLAMA_URL NTFY__BASE_URL NTFY__TOKEN STORAGE__PROVIDER; do
+ if rg -q "$forbidden" docker/docker-compose.yml docker/docker-compose.prod.yml; then
+ echo "Central Compose must not configure IHM-managed setting: $forbidden" >&2
+ exit 1
+ fi
+done
+
for required in HEIMDALL_CENTRAL_URL HEIMDALL_SITE_TOKEN; do
if env "$required=" AGENT_IMAGE_REFERENCE=heimdall-agent:ci docker compose \
--env-file .env.example -f docker/docker-compose.agent.yml config --quiet >/dev/null 2>&1; then
diff --git a/src/Heimdall.Infrastructure/HealthChecks/AiHealthCheck.cs b/src/Heimdall.Infrastructure/HealthChecks/AiHealthCheck.cs
index da95b16..a57c09e 100644
--- a/src/Heimdall.Infrastructure/HealthChecks/AiHealthCheck.cs
+++ b/src/Heimdall.Infrastructure/HealthChecks/AiHealthCheck.cs
@@ -85,7 +85,7 @@ public sealed class AiHealthCheck : IHealthCheck
return HealthCheckResult.Healthy("AI backend not configured");
}
- /// AppSettings (ai.*) d'abord, fallback env (migration douce, ticket #80).
+ /// Les URL de service IA sont lues dans les AppSettings globaux.
private async Task<(string? Cpai, string? Ollama)> ResolveUrlsAsync(CancellationToken ct)
{
using var scope = _services.CreateScope();
@@ -94,8 +94,7 @@ public sealed class AiHealthCheck : IHealthCheck
var cpai = await AppSettingReader.GetAsync(db, "ai.cpaiUrl", ct).ConfigureAwait(false)
?? Environment.GetEnvironmentVariable("CPAI_URL");
- var ollama = await AppSettingReader.GetAsync(db, "ai.ollamaUrl", ct).ConfigureAwait(false)
- ?? Environment.GetEnvironmentVariable("OLLAMA_URL");
+ var ollama = await AppSettingReader.GetAsync(db, "ai.ollamaUrl", ct).ConfigureAwait(false);
return (cpai, ollama);
}
diff --git a/src/Heimdall.Infrastructure/Services/EmailService.cs b/src/Heimdall.Infrastructure/Services/EmailService.cs
index f48c8ba..e96e7e1 100644
--- a/src/Heimdall.Infrastructure/Services/EmailService.cs
+++ b/src/Heimdall.Infrastructure/Services/EmailService.cs
@@ -3,7 +3,6 @@ using System.Net.Mail;
using Heimdall.Application.Common;
using Heimdall.Application.Services;
using Heimdall.Infrastructure.Settings;
-using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@@ -13,12 +12,10 @@ public class EmailService : IEmailService
{
private readonly ILogger _logger;
private readonly IServiceProvider _services;
- private readonly IConfiguration _configuration;
- public EmailService(IServiceProvider services, IConfiguration configuration, ILogger logger)
+ public EmailService(IServiceProvider services, ILogger logger)
{
_services = services;
- _configuration = configuration;
_logger = logger;
}
@@ -69,9 +66,8 @@ public class EmailService : IEmailService
}
///
- /// Source de vérité : AppSettings en base (email.*), avec fallback
- /// config/appsettings puis env (migration douce, ticket #80). Relu à
- /// chaque envoi pour prendre en compte les modifications de l'UI.
+ /// Source de vérité : AppSettings globaux en base (email.*), relus à
+ /// chaque envoi pour prendre en compte les modifications de l'IHM.
///
private async Task<(string? SmtpHost, int SmtpPort, string? Username, string? Password,
string? FromAddress, string? FromName, bool UseSsl)> ResolveConfigAsync(CancellationToken ct)
@@ -79,37 +75,23 @@ public class EmailService : IEmailService
using var scope = _services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService();
- var smtpHost = await AppSettingReader.GetAsync(db, "email.smtpHost", ct).ConfigureAwait(false)
- ?? _configuration.GetValue("Email:SmtpHost")
- ?? Environment.GetEnvironmentVariable("EMAIL__SMTP_HOST");
+ var smtpHost = await AppSettingReader.GetAsync(db, "email.smtpHost", ct).ConfigureAwait(false);
var smtpPort = await AppSettingReader.GetIntAsync(db, "email.smtpPort", -1, ct).ConfigureAwait(false);
if (smtpPort < 0)
- smtpPort = _configuration.GetValue("Email:SmtpPort")
- ?? (int.TryParse(Environment.GetEnvironmentVariable("EMAIL__SMTP_PORT"), out var port) ? port : 587);
+ smtpPort = 587;
- var username = await AppSettingReader.GetAsync(db, "email.username", ct).ConfigureAwait(false)
- ?? _configuration.GetValue("Email:Username")
- ?? Environment.GetEnvironmentVariable("EMAIL__USERNAME");
+ var username = await AppSettingReader.GetAsync(db, "email.username", ct).ConfigureAwait(false);
- var password = await AppSettingReader.GetAsync(db, "email.password", ct).ConfigureAwait(false)
- ?? _configuration.GetValue("Email:Password")
- ?? Environment.GetEnvironmentVariable("EMAIL__PASSWORD");
+ var password = await AppSettingReader.GetAsync(db, "email.password", ct).ConfigureAwait(false);
var fromAddress = await AppSettingReader.GetAsync(db, "email.fromAddress", ct).ConfigureAwait(false)
- ?? _configuration.GetValue("Email:FromAddress")
- ?? Environment.GetEnvironmentVariable("EMAIL__FROM_ADDRESS") ?? "noreply@heimdall.local";
+ ?? "noreply@heimdall.local";
var fromName = await AppSettingReader.GetAsync(db, "email.fromName", ct).ConfigureAwait(false)
- ?? _configuration.GetValue("Email:FromName")
- ?? Environment.GetEnvironmentVariable("EMAIL__FROM_NAME") ?? "Heimdall";
+ ?? "Heimdall";
var useSsl = await AppSettingReader.GetBoolAsync(db, "email.useSsl", true, ct).ConfigureAwait(false);
- if (_configuration.GetValue("Email:UseSsl") is { } cfgSsl)
- useSsl = cfgSsl;
- else if (bool.TryParse(Environment.GetEnvironmentVariable("EMAIL__USE_SSL"), out var envSsl))
- useSsl = envSsl;
-
return (smtpHost, smtpPort, username, password, fromAddress, fromName, useSsl);
}
}
diff --git a/src/Heimdall.Infrastructure/Services/NtfyService.cs b/src/Heimdall.Infrastructure/Services/NtfyService.cs
index 0b60698..89e5bbd 100644
--- a/src/Heimdall.Infrastructure/Services/NtfyService.cs
+++ b/src/Heimdall.Infrastructure/Services/NtfyService.cs
@@ -4,7 +4,6 @@ using System.Text.Json;
using Heimdall.Application.Common;
using Heimdall.Application.Services;
using Heimdall.Infrastructure.Settings;
-using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@@ -14,15 +13,13 @@ public class NtfyService : INtfyService
{
private readonly IHttpClientFactory _httpClientFactory;
private readonly IServiceProvider _services;
- private readonly IConfiguration _configuration;
private readonly ILogger _logger;
public NtfyService(IHttpClientFactory httpClientFactory, IServiceProvider services,
- IConfiguration configuration, ILogger logger)
+ ILogger logger)
{
_httpClientFactory = httpClientFactory;
_services = services;
- _configuration = configuration;
_logger = logger;
}
@@ -77,9 +74,8 @@ public class NtfyService : INtfyService
}
///
- /// Source de vérité : AppSettings en base (ntfy.*), avec fallback
- /// config/appsettings puis env (migration douce, ticket #80). Relu à
- /// chaque envoi pour prendre en compte les modifications de l'UI.
+ /// Source de vérité : AppSettings globaux en base (ntfy.*), relus à
+ /// chaque envoi pour prendre en compte les modifications de l'IHM.
///
private async Task<(string BaseUrl, string? Token)> ResolveConfigAsync(CancellationToken ct)
{
@@ -87,13 +83,9 @@ public class NtfyService : INtfyService
var db = scope.ServiceProvider.GetRequiredService();
var baseUrl = await AppSettingReader.GetAsync(db, "ntfy.baseurl", ct).ConfigureAwait(false)
- ?? _configuration.GetValue("Ntfy:BaseUrl")
- ?? Environment.GetEnvironmentVariable("NTFY__BASE_URL")
- ?? "http://ntfy:80";
+ ?? string.Empty;
- var token = await AppSettingReader.GetAsync(db, "ntfy.token", ct).ConfigureAwait(false)
- ?? _configuration.GetValue("Ntfy:Token")
- ?? Environment.GetEnvironmentVariable("NTFY__TOKEN");
+ var token = await AppSettingReader.GetAsync(db, "ntfy.token", ct).ConfigureAwait(false);
return (baseUrl, token);
}
diff --git a/src/Heimdall.Infrastructure/Storage/StorageProviderFactory.cs b/src/Heimdall.Infrastructure/Storage/StorageProviderFactory.cs
index d7b8c59..99c1eb6 100644
--- a/src/Heimdall.Infrastructure/Storage/StorageProviderFactory.cs
+++ b/src/Heimdall.Infrastructure/Storage/StorageProviderFactory.cs
@@ -10,8 +10,7 @@ namespace Heimdall.Infrastructure.Storage;
///
/// Resolves the active storage provider from the global settings
-/// (storage.provider = Local | S3) with env fallback
-/// (STORAGE__PROVIDER). Reads the DB each resolution so a change made
+/// (storage.provider = Local | S3). Reads the DB each resolution so a change made
/// in the UI is picked up without restart (broadcast reload on top).
///
public sealed class StorageProviderFactory : IStorageProvider, Heimdall.Application.Common.IStorageObjectDeletion
@@ -55,8 +54,6 @@ public sealed class StorageProviderFactory : IStorageProvider, Heimdall.Applicat
using var scope = _services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService();
var provider = GetSetting(db, "storage.provider");
- if (string.IsNullOrWhiteSpace(provider))
- provider = Environment.GetEnvironmentVariable("STORAGE__PROVIDER");
if (string.IsNullOrWhiteSpace(provider))
provider = "Local";
@@ -277,12 +274,11 @@ public sealed class StorageProviderFactory : IStorageProvider, Heimdall.Applicat
var db = scope.ServiceProvider.GetRequiredService();
var configuredProvider = GetSetting(db, "storage.provider");
- var environmentProvider = Environment.GetEnvironmentVariable("STORAGE__PROVIDER");
var provider = !string.IsNullOrWhiteSpace(providerOverride)
? providerOverride
: !string.IsNullOrWhiteSpace(configuredProvider)
? configuredProvider
- : !string.IsNullOrWhiteSpace(environmentProvider) ? environmentProvider : "Local";
+ : "Local";
if (provider.Equals("S3", StringComparison.OrdinalIgnoreCase))
{
diff --git a/src/Heimdall.Web/Components/Pages/SettingsPage.razor b/src/Heimdall.Web/Components/Pages/SettingsPage.razor
index 530eb2b..b256208 100644
--- a/src/Heimdall.Web/Components/Pages/SettingsPage.razor
+++ b/src/Heimdall.Web/Components/Pages/SettingsPage.razor
@@ -23,6 +23,7 @@
+
diff --git a/src/Heimdall.Web/Components/Settings/UpdatesSettingsSection.razor b/src/Heimdall.Web/Components/Settings/UpdatesSettingsSection.razor
new file mode 100644
index 0000000..1990eb0
--- /dev/null
+++ b/src/Heimdall.Web/Components/Settings/UpdatesSettingsSection.razor
@@ -0,0 +1,58 @@
+@namespace Heimdall.Web.Components.Settings
+@inject HeimdallApiClient Api
+@inject ISnackbar Snackbar
+
+
+ Mises à jour
+
+ Source globale des versions et des manifestes d’images Heimdall. L’URL doit être une adresse HTTPS absolue.
+
+
+
+
+@code {
+ private const string SettingKey = "updates.releaseapiurl";
+ private List _settings = [];
+ private string _url = string.Empty;
+
+ protected override async Task OnInitializedAsync()
+ {
+ try
+ {
+ _settings = await Api.GetSettingsAsync();
+ _url = _settings.FirstOrDefault(s => s.Key.Equals(SettingKey, StringComparison.OrdinalIgnoreCase))?.Value ?? string.Empty;
+ }
+ catch
+ {
+ _settings = [];
+ }
+ }
+
+ private async Task SaveUrlAsync(string value)
+ {
+ value = value?.Trim() ?? string.Empty;
+ if (value.Length > 0 && (!Uri.TryCreate(value, UriKind.Absolute, out var uri) || uri.Scheme != Uri.UriSchemeHttps))
+ {
+ Snackbar.Add("L’URL doit être une adresse HTTPS absolue.", Severity.Warning);
+ return;
+ }
+
+ var existing = _settings.FirstOrDefault(s => s.Key.Equals(SettingKey, StringComparison.OrdinalIgnoreCase));
+ try
+ {
+ if (existing is null)
+ await Api.CreateSettingAsync(new CreateAppSettingRequest(SettingKey, value, "updates", "API de publication Heimdall", "string", null, false));
+ else
+ await Api.UpdateSettingAsync(existing.Key, new UpdateAppSettingRequest(value, existing.Description, "updates", "string", null, false));
+ _url = value;
+ _settings = await Api.GetSettingsAsync();
+ Snackbar.Add("Source des mises à jour enregistrée.", Severity.Success);
+ }
+ catch (Exception ex)
+ {
+ Snackbar.Add($"Impossible d’enregistrer la source des mises à jour : {ex.Message}", Severity.Error);
+ }
+ }
+}
diff --git a/src/Heimdall.Web/Controllers/UpdatesController.cs b/src/Heimdall.Web/Controllers/UpdatesController.cs
index 84abca3..e07c80c 100644
--- a/src/Heimdall.Web/Controllers/UpdatesController.cs
+++ b/src/Heimdall.Web/Controllers/UpdatesController.cs
@@ -3,7 +3,9 @@ using System.Security.Cryptography;
using System.Text.Json;
using System.Text.Json.Serialization;
using Heimdall.Infrastructure.Security;
+using Heimdall.Infrastructure.Settings;
using Heimdall.Application.Services;
+using Heimdall.Application.Common;
using Heimdall.Api.Security;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -20,7 +22,7 @@ public class UpdatesController : ControllerBase
private readonly ILogger _logger;
private readonly IConfigBroadcastService _configBroadcast;
private readonly ResourceAccess _resourceAccess;
- private readonly IConfiguration _configuration;
+ private readonly IServiceProvider _services;
private static readonly JsonSerializerOptions Json = new()
{
@@ -32,13 +34,13 @@ public class UpdatesController : ControllerBase
private static LatestReleaseCache? _cache;
private static readonly TimeSpan CacheDuration = TimeSpan.FromHours(1);
public UpdatesController(IHttpClientFactory httpClientFactory, ILogger logger,
- IConfigBroadcastService configBroadcast, ResourceAccess resourceAccess, IConfiguration configuration)
+ IConfigBroadcastService configBroadcast, ResourceAccess resourceAccess, IServiceProvider services)
{
_httpClientFactory = httpClientFactory;
_logger = logger;
_configBroadcast = configBroadcast;
_resourceAccess = resourceAccess;
- _configuration = configuration;
+ _services = services;
}
[AllowAnonymous]
@@ -46,15 +48,16 @@ public class UpdatesController : ControllerBase
[ProducesResponseType(typeof(LatestReleaseResponse), StatusCodes.Status200OK)]
public async Task GetLatestRelease(CancellationToken ct)
{
- var cached = GetCached(_configuration["Updates:ReleaseApiUrl"]);
+ var source = await GetReleaseApiUrlAsync(ct);
+ var cached = GetCached(source);
if (cached is not null && !IsStale(cached))
return Ok(cached.Response);
if (cached is not null && IsStale(cached))
{
- _ = RefreshCacheAsync(ct);
+ _ = RefreshCacheAsync(source, ct);
return Ok(cached.Response);
}
- var result = await FetchLatestReleaseAsync(ct);
+ var result = await FetchLatestReleaseAsync(source, ct);
if (result is null)
return StatusCode(502, new { error = "Failed to fetch release info" });
return Ok(result);
@@ -68,14 +71,15 @@ public class UpdatesController : ControllerBase
{
var requester = await _resourceAccess.ResolveAsync(User, ct);
if (requester is null || requester.Kind != RequesterKind.Agent) return Forbid();
- var cached = GetCached(_configuration["Updates:ReleaseApiUrl"]);
+ var source = await GetReleaseApiUrlAsync(ct);
+ var cached = GetCached(source);
if (cached is not null && !IsStale(cached)) return Ok(cached.Response);
if (cached is not null)
{
- _ = RefreshCacheAsync(ct);
+ _ = RefreshCacheAsync(source, ct);
return Ok(cached.Response);
}
- var result = await FetchLatestReleaseAsync(ct);
+ var result = await FetchLatestReleaseAsync(source, ct);
return result is null ? StatusCode(502, new { error = "Failed to fetch release info" }) : Ok(result);
}
@@ -85,8 +89,9 @@ public class UpdatesController : ControllerBase
public async Task TriggerAgentUpdate(Guid id, CancellationToken ct)
{
_logger.LogInformation("Manual update requested for agent {AgentId}", id);
- var cached = GetCached(_configuration["Updates:ReleaseApiUrl"]);
- var release = cached is not null && !IsStale(cached) ? cached.Response : await FetchLatestReleaseAsync(ct);
+ var source = await GetReleaseApiUrlAsync(ct);
+ var cached = GetCached(source);
+ var release = cached is not null && !IsStale(cached) ? cached.Response : await FetchLatestReleaseAsync(source, ct);
if (release is null)
return StatusCode(502, new { error = "Failed to fetch release info" });
if (!await _configBroadcast.RequestAgentUpdate(id, ct))
@@ -94,14 +99,20 @@ public class UpdatesController : ControllerBase
return Accepted(new { agentId = id, command = "update-check", dispatched = true, release });
}
- private async Task FetchLatestReleaseAsync(CancellationToken ct)
+ private async Task GetReleaseApiUrlAsync(CancellationToken ct)
+ {
+ using var scope = _services.CreateScope();
+ var db = scope.ServiceProvider.GetRequiredService();
+ return await AppSettingReader.GetAsync(db, "updates.releaseapiurl", ct).ConfigureAwait(false);
+ }
+
+ private async Task FetchLatestReleaseAsync(string? source, CancellationToken ct)
{
- var source = _configuration["Updates:ReleaseApiUrl"];
if (!Uri.TryCreate(source, UriKind.Absolute, out var sourceUri) ||
sourceUri.Scheme != Uri.UriSchemeHttps || !string.IsNullOrEmpty(sourceUri.UserInfo) ||
!string.IsNullOrEmpty(sourceUri.Fragment))
{
- _logger.LogError("Updates:ReleaseApiUrl must be an absolute HTTPS URL without credentials or fragment");
+ _logger.LogError("The global release API setting must be an absolute HTTPS URL without credentials or fragment");
return null;
}
try
@@ -219,7 +230,10 @@ public class UpdatesController : ControllerBase
[JsonPropertyName("digest")] public string Digest { get; init; } = string.Empty;
}
- private async Task RefreshCacheAsync(CancellationToken ct) { try { await FetchLatestReleaseAsync(ct); } catch { } }
+ private async Task RefreshCacheAsync(string? source, CancellationToken ct)
+ {
+ try { await FetchLatestReleaseAsync(source, ct); } catch { }
+ }
private static LatestReleaseCache? GetCached(string? source)
{
lock (_cacheLock) return _cache?.Source == source ? _cache : null;
diff --git a/src/Heimdall.Web/Program.cs b/src/Heimdall.Web/Program.cs
index 3db3f9e..ead287d 100644
--- a/src/Heimdall.Web/Program.cs
+++ b/src/Heimdall.Web/Program.cs
@@ -264,7 +264,7 @@ public partial class Program
{
var defaults = new Dictionary
{
- ["storage.provider"] = Environment.GetEnvironmentVariable("STORAGE__PROVIDER") ?? "Local",
+ ["storage.provider"] = "Local",
["storage.local.path"] = Environment.GetEnvironmentVariable("STORAGE__LOCAL__PATH") ?? "./data/storage",
["storage.s3.endpoint"] = Environment.GetEnvironmentVariable("ALARIK_ENDPOINT")
?? Environment.GetEnvironmentVariable("S3_ENDPOINT"),
@@ -302,17 +302,18 @@ public partial class Program
var defaults = new Dictionary
{
- ["ntfy.baseUrl"] = Environment.GetEnvironmentVariable("NTFY__BASE_URL") ?? "https://ntfy.sh",
- ["ntfy.token"] = Environment.GetEnvironmentVariable("NTFY__TOKEN"),
- ["email.fromAddress"] = Environment.GetEnvironmentVariable("EMAIL__FROM_ADDRESS"),
- ["email.fromName"] = Environment.GetEnvironmentVariable("EMAIL__FROM_NAME"),
- ["email.smtpHost"] = Environment.GetEnvironmentVariable("EMAIL__SMTP_HOST"),
- ["email.smtpPort"] = Environment.GetEnvironmentVariable("EMAIL__SMTP_PORT") ?? "587",
- ["email.username"] = Environment.GetEnvironmentVariable("EMAIL__USERNAME"),
- ["email.password"] = Environment.GetEnvironmentVariable("EMAIL__PASSWORD"),
- ["email.useSsl"] = Environment.GetEnvironmentVariable("EMAIL__USE_SSL") ?? "true",
+ ["ntfy.baseUrl"] = string.Empty,
+ ["ntfy.token"] = string.Empty,
+ ["email.fromAddress"] = string.Empty,
+ ["email.fromName"] = "Heimdall",
+ ["email.smtpHost"] = string.Empty,
+ ["email.smtpPort"] = "587",
+ ["email.username"] = string.Empty,
+ ["email.password"] = string.Empty,
+ ["email.useSsl"] = "true",
["ai.cpaiUrl"] = Environment.GetEnvironmentVariable("CPAI_URL"),
- ["ai.ollamaUrl"] = Environment.GetEnvironmentVariable("OLLAMA_URL"),
+ ["ai.ollamaUrl"] = string.Empty,
+ ["updates.releaseapiurl"] = string.Empty,
["ai.detection.enabled"] = Environment.GetEnvironmentVariable("AI__DETECTION__ENABLED") ?? "true",
["log.level"] = Environment.GetEnvironmentVariable("LOG__LEVEL") ?? "info",
["log.retentionDays"] = Environment.GetEnvironmentVariable("LOG__RETENTION_DAYS") ?? "7",
@@ -332,7 +333,8 @@ public partial class Program
if (existingKeys.Contains(key)) continue;
var agentScoped = !(key.StartsWith("ntfy.", StringComparison.Ordinal)
|| key.StartsWith("email.", StringComparison.Ordinal)
- || key.StartsWith("sentry.", StringComparison.Ordinal));
+ || key.StartsWith("sentry.", StringComparison.Ordinal)
+ || key.StartsWith("updates.", StringComparison.Ordinal));
var category = ResolveCategory(key);
groupDb.AppSettings.Add(new Heimdall.Domain.Entities.AppSetting(
key, value ?? string.Empty,
@@ -350,6 +352,7 @@ public partial class Program
"email.useSsl" => "Utiliser SSL/TLS pour SMTP",
"ai.cpaiUrl" => "URL CodeProject.AI",
"ai.ollamaUrl" => "URL Ollama",
+ "updates.releaseapiurl" => "API des versions Heimdall (HTTPS)",
"ai.detection.enabled" => "Détection IA activée par défaut",
"log.level" => "Niveau de log global (agents + central)",
"log.retentionDays" => "Rétention des logs agents (jours)",
diff --git a/src/Heimdall.Web/Services/SameOriginHttpMessageHandler.cs b/src/Heimdall.Web/Services/SameOriginHttpMessageHandler.cs
index f7feedc..ae8aae9 100644
--- a/src/Heimdall.Web/Services/SameOriginHttpMessageHandler.cs
+++ b/src/Heimdall.Web/Services/SameOriginHttpMessageHandler.cs
@@ -23,8 +23,7 @@ public static class ApiBaseUrlResolver
/// Returns the explicitly configured URL, or null when unset.
public static string? ResolveConfigured(IConfiguration configuration) =>
- configuration.GetValue("ApiBaseUrl")
- ?? Environment.GetEnvironmentVariable("API_BASE_URL");
+ configuration.GetValue("ApiBaseUrl");
///
/// Effective origin for the current request (scheme://host). Returns null
diff --git a/todo.md b/todo.md
index d2b847d..03c551f 100644
--- a/todo.md
+++ b/todo.md
@@ -24,7 +24,7 @@ Ce fichier remplace les rapports de `docs/audits/` et constitue le suivi courant
- [ ] **Heartbeat / failover** La PR #87 aligne le délai Offline sur la fréquence configurée (globalement ou par Agent), supprime le job concurrent qui pouvait empêcher la réaffectation, et relance celle-ci pour les Agents Offline qui gardent des caméras actives. La plage est limitée à 5–300 s comme côté Agent (timeout effectif maximal : 660 s). Les fixtures de failover utilisent un heartbeat vieux de 900 s pour tester un Agent effectivement expiré. Le run PR #276 a validé build/tests et les scans des images serveur et Agent; la validation sur plusieurs Agents reste à faire.
- [ ] **PIPE-10 / FEAT-05** La PR #74 fait remonter les erreurs ntfy; la PR #76 ajoute une outbox SQL atomique avec état, leases, reprise périodique et unicité par notification/canal. Sa CI (run #242) a validé les tests et scans d’images. La PR #110 ajoute des tests PostgreSQL du succès, du backoff après erreur, de la reprise de lease expirée, de l’ignorance des livraisons différées ou déjà prises et du routage Hangfire par canal. Le run PR #332 a passé les 155 tests d’intégration et les 35 E2E sans test ignoré, les builds/scans des deux images et `CI policy`; la publication Docker Hub a été ignorée comme prévu. Restent les essais SMTP/ntfy réels. La livraison reste au moins une fois : une panne après acceptation fournisseur mais avant l’acquittement SQL peut produire un doublon; aucune garantie exactement une fois n’est possible avec ces interfaces.
- [ ] **OPS-02** Les PR #62, #63 et #106 protègent les références de caméras supprimées logiquement, enregistrent l'inventaire des destinations avant upload et font parcourir ces destinations par le nettoyage final. Le run PR #317 a passé les 284 tests Infrastructure, dont les scénarios de changement de destination (snapshot référencé conservé, puis orphelin supprimé) et de S3 historique inaccessible (références conservées). Restent les objets recording tant que FEAT-02 n'a pas de producteur, les lignes historiques sans provenance (ne pas deviner), et la validation du changement de provider sur stockage déployé.
-- [ ] **OPS-05 / AGENT-06** Les Compose sont simplifiés en un noyau Central + PostgreSQL, un Compose Agent autonome et des Compose facultatifs séparés. Le parcours Agent généré par l’IHM est conservé, utilise l’image et le digest fournis par Central, et le réseau hôte nécessaire à la découverte caméra est couvert par un test. La clé publique de release reste montée depuis un fichier indépendant de Central, en lecture seule. La PR #114 sépare Central + PostgreSQL, l’Agent autonome et les services optionnels; son script Compose local passe. Restent l’installation des clés de signature CI/publication réelle, puis la validation de release, digest/signature, mise à jour native et Docker, arrêt propre et rollback.
+- [ ] **OPS-05 / AGENT-06** Les Compose sont simplifiés en un noyau Central + PostgreSQL, un Compose Agent autonome et des Compose facultatifs séparés. Le parcours Agent généré par l’IHM est conservé, utilise l’image et le digest fournis par Central, et le réseau hôte nécessaire à la découverte caméra est couvert par un test. La clé publique de release reste montée depuis un fichier indépendant de Central, en lecture seule. La PR #114 sépare Central + PostgreSQL, l’Agent autonome et les services optionnels; elle retire aussi les réglages métier (SMTP, ntfy, Ollama, stockage, source des releases et URL API) du Compose pour les gérer par l’IHM avec portée globale, en laissant les destinations de notification à leur portée site/utilisateur. Restent le passage CI, l’installation des clés de signature CI/publication réelle, puis la validation de release, digest/signature, mise à jour native et Docker, arrêt propre et rollback.
- [ ] **AGENT-08** Valider reconnexion, remplacement atomique de configuration caméra et ACK persisté sur Agent déployé.
- [ ] **AGENT-09** La PR #101 aligne `heimdall.ai.pipeline.level` sur les transitions réelles (inférence lente, moteur indisponible, saturation CPU et récupération), sans ratio cumulatif périmé. La PR #102 ajoute `heimdall.ai.inference.queue.depth` et `heimdall.ai.inference.queue.rejected` pour rendre visibles le backlog ONNX et les frames rejetées quand la file est pleine. Restent à mesurer les seuils de capture et la santé d'enregistrement sous panne caméra/modèle/disque, puis valider ces alertes sur matériel représentatif.
- [ ] **AGENT-10** Tester charge, redémarrages rapides et arrêt FFmpeg/ONNX sous contrainte sur matériel représentatif.
@@ -46,7 +46,7 @@ Ce fichier remplace les rapports de `docs/audits/` et constitue le suivi courant
- [x] **Localisation #142** Le shell, le tableau de bord, le profil et les pages/composants UI utilisent les ressources FR/EN, avec français par défaut, bascule sans rechargement et clés complètes. Les notifications d’événements, les digests, les emails d’inscription/réinitialisation et le test SMTP utilisent aussi les ressources serveur FR/EN. La CI PR #93 (run #303) a passé le build, les suites .NET (1 730 tests), les 34 tests E2E, le contrôle NuGet et les builds/scans des images serveur et Agent.
- [ ] **Métriques #14** Les endpoints Prometheus `/metrics` Web et Agent sont mappés. La PR #68 ajoute et valide `heimdall.signalr.connections_by_hub` sur les cinq hubs Web. La jauge de viewers existe, mais aucun producteur WebRTC n'existe avant FEAT-01. Restent la validation de scraping sur un déploiement et l'évolution réelle des mesures.
- [x] Ajouter `.agents/skills/secure-env-secrets/SKILL.md` : procédures pour lire/écrire les secrets fournis par l'utilisateur dans l'environnement local, avec stockage persistant optionnel hors dépôt, permissions utilisateur uniquement et sans exposer la valeur. Le skill ne configure pas les secrets des workflows distants.
-- [ ] Vérifier readiness et alertes pour modèle absent, file pleine, backlog, disque, jobs bloqués, perte de configuration et échec de livraison. Le contrôle stockage est aligné sur le fournisseur actif (settings DB/env), avec probe d’écriture locale, probe du bucket S3 sélectionné et timeout borné ; les health checks IA convertissent aussi leurs timeouts internes en état dégradé tout en propageant l’annulation appelante. La PR #109 ajoute les tests de `/readyz` sain/stockage mal configuré (sans fuite de configuration), de `/health/live` avec IA optionnelle absente et de diagnostics Agent lorsque le modèle ou le flux de capture manque ; le run PR #327 a passé 383 tests Agent, 150 tests d’intégration PostgreSQL, 35 E2E sans test ignoré, les builds/scans serveur/Agent et `CI policy`. La PR #111, mergée, ajoute les diagnostics de saturation CPU et garantit que cette saturation reste `Unhealthy` même quand la capture est également périmée ; le run PR #335 a passé les tests, scans serveur/Agent et `CI policy`. La PR #112, mergée après les runs #370, ajoute les profondeurs des files snapshots et inférence ainsi que les snapshots abandonnés. La PR #113 ajoute le taux d’occupation disque au diagnostic santé Agent sans définir de seuil de dégradation ; ses contrôles seront relancés sur sa base rebasée. Restent les alertes file pleine, backlog, disque, les jobs bloqués et les pannes à valider sur déploiement réel.
+- [ ] Vérifier readiness et alertes pour modèle absent, file pleine, backlog, disque, jobs bloqués, perte de configuration et échec de livraison. Le contrôle stockage est aligné sur le fournisseur actif dans les réglages DB de l’IHM, avec probe d’écriture locale, probe du bucket S3 sélectionné et timeout borné ; les health checks IA convertissent aussi leurs timeouts internes en état dégradé tout en propageant l’annulation appelante. La PR #109 ajoute les tests de `/readyz` sain/stockage mal configuré (sans fuite de configuration), de `/health/live` avec IA optionnelle absente et de diagnostics Agent lorsque le modèle ou le flux de capture manque ; le run PR #327 a passé 383 tests Agent, 150 tests d’intégration PostgreSQL, 35 E2E sans test ignoré, les builds/scans serveur/Agent et `CI policy`. La PR #111, mergée, ajoute les diagnostics de saturation CPU et garantit que cette saturation reste `Unhealthy` même quand la capture est également périmée ; le run PR #335 a passé les tests, scans serveur/Agent et `CI policy`. La PR #112, mergée après les runs #370, ajoute les profondeurs des files snapshots et inférence ainsi que les snapshots abandonnés. La PR #113, mergée, ajoute le taux d’occupation disque au diagnostic santé Agent sans définir de seuil de dégradation. Restent les alertes file pleine, backlog, disque, les jobs bloqués et les pannes à valider sur déploiement réel.
- [ ] Actualiser les guides après chaque changement d'infrastructure, routes/API et statut produit ; distinguer implémenté, validé, partiel et prévu. Vérifier une installation depuis la documentation.
## Corrections déjà livrées à préserver