fc86e8bfe1
Secrets.Ui components inject the SHARED ZB.MOM.WW.Audit.IAuditWriter seam, which is deliberately distinct from the repo's own Commons IAuditWriter — the G-4 adoption mounted the UI without registering it, so component activation threw and the page 500'd on every render (hidden behind the login wall; it plausibly never worked). Fix: CentralSharedSeamAuditWriter forwards the shared seam into the central direct-write path (ICentralAuditWriter -> dbo.AuditLog) — NOT the site SQLite chain, which is never resolved on central and has no forwarder there. Registered in the Central composition root next to the Secrets UI authorization wiring. Regression pin: CentralCompositionRootTests resolves the full Secrets.Ui component injection set (ISecretStore / ISecretCipher / shared IAuditWriter) out of the REAL Program.cs via WebApplicationFactory, plus a type check that the seam is the central bridge. Red on the previous commit; the defect class is invisible until the DI graph is actually built. Live-proven on the local docker cluster: /admin/secrets 200 + interactive (Blazor circuit + working @onclick), and secret.add / secret.delete events (both outcomes) landed in central dbo.AuditLog via the bridge. Closes #22 Claude-Session: https://claude.ai/code/session_01BL2Vu1ESDQ9SCN4gVKkdts
31 lines
1.5 KiB
C#
31 lines
1.5 KiB
C#
using ZB.MOM.WW.Audit;
|
|
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Services;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.Host.Services;
|
|
|
|
/// <summary>
|
|
/// Central-only bridge from the shared-library audit seam
|
|
/// (<see cref="ZB.MOM.WW.Audit.IAuditWriter"/>) to the central direct-write path
|
|
/// (<see cref="ICentralAuditWriter"/> → dbo.AuditLog). Shared-lib UI components —
|
|
/// today the Secrets.Ui components mounted at /admin/secrets — inject the shared
|
|
/// seam, which is deliberately distinct from the repo's own
|
|
/// <see cref="Commons.Interfaces.Services.IAuditWriter"/> (ScadaBridge#22).
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// The target is <see cref="ICentralAuditWriter"/> and NOT the repo's own site
|
|
/// writer chain: the site SQLite chain is registered on central but by design
|
|
/// never resolved there, and events written to it would dead-end in a local file
|
|
/// that no forwarding sidecar drains on a central node. The best-effort contract
|
|
/// (audit failures never abort the user-facing action) is inherited from
|
|
/// <see cref="AuditLog.Central.CentralAuditWriter"/>, which swallows and logs —
|
|
/// so this forward needs no try/catch of its own.
|
|
/// </remarks>
|
|
/// <param name="central">The central direct-write audit path to forward into.</param>
|
|
public sealed class CentralSharedSeamAuditWriter(ICentralAuditWriter central)
|
|
: ZB.MOM.WW.Audit.IAuditWriter
|
|
{
|
|
/// <inheritdoc />
|
|
public Task WriteAsync(AuditEvent auditEvent, CancellationToken cancellationToken = default)
|
|
=> central.WriteAsync(auditEvent, cancellationToken);
|
|
}
|