feat(secrets): Secrets:Store:Provider=SqlServer — central pair shares one SQL secret store without the hub
This commit is contained in:
@@ -97,6 +97,17 @@ public static class StartupValidator
|
||||
value => string.IsNullOrWhiteSpace(value)
|
||||
|| (Enum.TryParse<InboundApiKeyStoreProvider>(value, ignoreCase: true, out var provider)
|
||||
&& Enum.IsDefined(provider)),
|
||||
"must be 'Sqlite' or 'SqlServer' when set")
|
||||
// The central shared secret store provider (Secrets:Store:Provider — a fleet that
|
||||
// ships secrets to sites on every artifact deploy needs a clustered central pair to
|
||||
// see the same secret set). Not required — an unset value defaults to Sqlite,
|
||||
// per-node, mirroring the inbound API-key store default above — but when it IS set,
|
||||
// it must be one of the two legal values so a typo fails fast at boot instead of
|
||||
// silently keeping the per-node SQLite store it looks like it opted out of.
|
||||
.Require("Secrets:Store:Provider",
|
||||
value => string.IsNullOrWhiteSpace(value)
|
||||
|| string.Equals(value, "Sqlite", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(value, "SqlServer", StringComparison.OrdinalIgnoreCase),
|
||||
"must be 'Sqlite' or 'SqlServer' when set"))
|
||||
// SeedNodes count (unconditional, after SiteId).
|
||||
.Require("ScadaBridge:Cluster:SeedNodes",
|
||||
@@ -226,20 +237,33 @@ public static class StartupValidator
|
||||
var role = configuration.GetSection("ScadaBridge:Node")["Role"];
|
||||
var seedNodes = configuration.GetSection("ScadaBridge:Cluster:SeedNodes").Get<List<string>>();
|
||||
var provider = InboundApiKeyStoreOptions.ReadProvider(configuration);
|
||||
var secretsStoreProvider = configuration["Secrets:Store:Provider"];
|
||||
var isClusteredCentral = role == "Central" && seedNodes is { Count: >= 2 };
|
||||
|
||||
if (role == "Central"
|
||||
&& seedNodes is { Count: >= 2 }
|
||||
&& provider == InboundApiKeyStoreProvider.Sqlite)
|
||||
var warnings = new List<string>();
|
||||
|
||||
if (isClusteredCentral && provider == InboundApiKeyStoreProvider.Sqlite)
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
$"Inbound API keys use the per-node SQLite store on a {seedNodes.Count}-node central "
|
||||
warnings.Add(
|
||||
$"Inbound API keys use the per-node SQLite store on a {seedNodes!.Count}-node central "
|
||||
+ "cluster; a failover will reject every inbound client until keys are re-issued. Set "
|
||||
+ "ScadaBridge:InboundApi:ApiKeyStore:Provider=SqlServer (design 2026-09-02)."
|
||||
};
|
||||
+ "ScadaBridge:InboundApi:ApiKeyStore:Provider=SqlServer (design 2026-09-02).");
|
||||
}
|
||||
|
||||
return Array.Empty<string>();
|
||||
// Secrets:Store:Provider defaults to Sqlite (per-node) when unset, mirroring the inbound
|
||||
// API-key store default above — so this fires both when the key is absent and when it is
|
||||
// explicitly "Sqlite". A fleet that ships secrets to sites on every artifact deploy needs
|
||||
// both central nodes to deploy the SAME secret set; a per-node store means each node has
|
||||
// silently drifted the moment anyone edits a secret on only one of them.
|
||||
if (isClusteredCentral
|
||||
&& !string.Equals(secretsStoreProvider, "SqlServer", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
warnings.Add(
|
||||
"Secrets use a per-node SQLite store on a clustered central — each node would "
|
||||
+ "deploy its own secret set to sites; set Secrets:Store:Provider=SqlServer");
|
||||
}
|
||||
|
||||
return warnings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user