feat(storage): stockage configurable par l'IHM — providers Fichier + S3 (Fixes #78)

- IStorageProvider (Application) : Upload/Download/Delete/DeleteBatch/Health
- LocalStorageProvider : écriture atomique (tmp + move), anti path-traversal
- AlarikStorageProvider : S3-compatible (AWS SDK, ForcePathStyle), upload
  staging→final (atomique), batch delete 1000/appel (Correctif D6)
- StorageProviderFactory : provider résolu depuis les settings DB
  (storage.provider = Local|S3) avec fallback env, re-résolu à chaque appel
- Seed idempotent des clés storage.* (catégorie 'storage') au démarrage
- UI : section 'Stockage' dédiée dans SettingsPage (sélecteur Local/S3,
  champs conditionnels, clé secrète masquée, bouton Tester → POST
  /api/settings/storage/test)
- Tests : 6 LocalStorageProvider (roundtrip, delete, batch, traversal,
  health) ; Web 217/217, Infrastructure 177/177, Application 391/391
This commit is contained in:
Arnaud Dartois committed 2026-08-12 10:14:40 +02:00
1 parent 2e188e4dda
commit 7d6213696f
11 files changed
+685 -1

No files matched your search

@@ -12,6 +12,7 @@ using Heimdall.Infrastructure.Persistence;
using Heimdall.Infrastructure.Security;
using Heimdall.Infrastructure.Services;
using Heimdall.Infrastructure.Services.Discovery;
using Heimdall.Infrastructure.Storage;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
@@ -43,6 +44,12 @@ public static class DependencyInjection
services.AddScoped<IApplicationDbContext>(sp => sp.GetRequiredService<AppDbContext>());
// Stockage (spec Phase 8) — provider résolu depuis les settings DB
// (storage.provider = Local | S3), factory scoped (lit la config à
// chaque résolution → changement UI sans redémarrage).
services.AddSingleton<StorageProviderFactory>();
services.AddScoped<IStorageProvider>(sp => sp.GetRequiredService<StorageProviderFactory>());
// Health checks (spec 13.2) — PostgreSQL + dépendances optionnelles.
services.AddHealthChecks()
.AddDbContextCheck<AppDbContext>("postgres", tags: ["ready", "live"])