feat(site): DeployedSecretsMirror — per-node apply + decrypt-verify of deployed secrets

This commit is contained in:
Joseph Doherty
2026-09-28 18:52:44 -04:00
parent a35ee663c8
commit 25c25ccef9
6 changed files with 764 additions and 0 deletions
@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using ZB.MOM.WW.LocalDb;
@@ -9,6 +10,7 @@ using ZB.MOM.WW.ScadaBridge.SiteRuntime.Deployment;
using ZB.MOM.WW.ScadaBridge.SiteRuntime.Persistence;
using ZB.MOM.WW.ScadaBridge.SiteRuntime.Repositories;
using ZB.MOM.WW.ScadaBridge.SiteRuntime.Scripts;
using ZB.MOM.WW.ScadaBridge.SiteRuntime.Secrets;
using ZB.MOM.WW.ScadaBridge.SiteRuntime.Streaming;
namespace ZB.MOM.WW.ScadaBridge.SiteRuntime;
@@ -123,6 +125,21 @@ public static class ServiceCollectionExtensions
sp.GetRequiredService<IOptionsMonitor<SiteRuntimeOptions>>(),
sp.GetRequiredService<ILogger<ScriptRunSummaryFlushService>>()));
// Site-secrets artifact deploy (Task 9): per-node reconcile of the site-wide,
// LocalDb-replicated deployed_secrets table into THIS node's own ZB.MOM.WW.Secrets
// store. Runs on every site node — not a singleton, since mirrored_secrets (which
// names this node has already applied) is deliberately node-local, not replicated.
// Registered as a singleton (not just a hosted service) so ReconcileAsync can also
// be invoked synchronously — by tests, and by any future on-demand trigger (e.g.
// right after an artifact deploy lands secrets) — without waiting for the next tick.
// ISecretStore/ISecretResolver are registered by the Host's AddScadaBridgeSecrets
// (SecretsNodeRole.Site) — DI registration order does not matter, only that both
// calls happen before the provider is built, which SiteServiceRegistration.Configure
// guarantees.
services.TryAddSingleton(TimeProvider.System);
services.AddSingleton<DeployedSecretsMirror>();
services.AddHostedService(sp => sp.GetRequiredService<DeployedSecretsMirror>());
return services;
}