Files
lmxopcua/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/NativeAlarmAck.cs
T
Joseph Doherty dc0a24f224
v2-ci / unit-tests (push) Failing after 1h8m43s
feat(galaxy): operator-authenticated alarm ack — send Galaxy credential to mxaccessgw (#749)
mxaccessgw 488649c+ acknowledges by AuthenticateUser as the operator and
writing <alarm>.AckMsg, so AcknowledgeAlarmRequest now needs a real Galaxy
operator_user + operator_domain + operator_password. The OPC UA data plane is
API-key/anonymous and carries no Galaxy password, so the driver resolves the
account per ack:

1. the session's API key's Galaxy ack identity, set on AdminUI /apikeys and
   held ONLY in the encrypted Secrets store
   (otopcua/apikeys/<keyId>/galaxy-ack-{user,password}); a key with a user but
   no password secret is refused, never silently downgraded;
2. else the driver instance's AlarmAck fallback account (DriverConfig
   FallbackUser/FallbackDomain/FallbackPasswordSecretRef; secret:/${secret:}/
   env:/file:/dev: only — a literal is refused);
3. else DriverOperationRefusedException: nothing is sent, never an empty
   operator_user. Refusals are excluded from the resilience retry/breaker.

- Pins ZB.MOM.WW.MxGateway.Client/Contracts 0.2.1 -> 0.3.0 (vendored into
  nuget-packages/ from the Gitea feed, per the local-mxgw source mapping).
- The session ApiKeyId (not a secret) rides NativeAlarmAck ->
  RouteNativeAlarmAck -> RouteAlarmAck -> AlarmAcknowledgeRequest; the password
  is resolved in the driver and never travels through actor messages.
- The OPC UA principal + key id are appended to the AckMsg comment
  ("[OPC UA: <principal>, key <id>]") and logged, so a shared fallback
  account does not lose who acknowledged.
- Password never logged: GalaxyAckCredential.ToString omits it, the
  acknowledger scrubs it from every gateway message it echoes and withholds
  any exception that echoes it; audit rows carry only the key id.
- AdminUI: /apikeys "Ack identity" editor (set/remove; delete-key clears it),
  Galaxy driver form gains the fallback section.
- Synchronous OPC UA status for a refusal is follow-up #760 (the native ack
  path is fire-and-forget after the Part 9 method returns).

Tests: request mapping (password populated), password absent from logs and
exception text (mutation-checked), key-mapped / fallback / refused paths at
resolver and driver level, breaker non-trip, key-id propagation through node
manager and DriverHostActor, AdminUI service + form round-trip.

Closes #749
2026-11-06 16:23:00 -05:00

23 lines
1.7 KiB
C#

namespace ZB.MOM.WW.OtOpcUa.OpcUaServer;
/// <summary>
/// H6c — the payload routed when an OPC UA client Acknowledges a NATIVE (driver-fed, e.g. Galaxy)
/// Part 9 condition. The scripted-alarm engine does not own native conditions, so the node manager
/// branches a native condition's inbound Acknowledge to a separate
/// <see cref="OtOpcUaNodeManager.NativeAlarmAckRouter"/> seam (the host later wires it to the backing
/// driver) instead of the scripted <see cref="OtOpcUaNodeManager.AlarmCommandRouter"/>.
/// <para>
/// This record is intentionally OpcUaServer-local (the smallest scope) and Akka-free: it carries
/// exactly what the driver-bound router needs — the condition node id to resolve back to a driver
/// ref, the operator's acknowledge comment, and the authenticated operator's display name.
/// </para>
/// </summary>
/// <param name="ConditionNodeId">The folder-scoped condition NodeId identifier string — the same value
/// stored in <c>DriverHostActor._alarmNodeIdByDriverRef</c> (keyed by <c>(DriverInstanceId, FullName)</c>),
/// used to resolve the ack back to its backing driver.</param>
/// <param name="Comment">The operator's acknowledge comment text, or <c>null</c> when none was supplied.</param>
/// <param name="OperatorUser">The authenticated operator's display name (empty when none resolves).</param>
/// <param name="ApiKeyId">Public id of the API key the session authenticated with; null for anonymous. Not a
/// secret — the Galaxy driver uses it to find the key's Galaxy ack identity (lmxopcua#749).</param>
public sealed record NativeAlarmAck(string ConditionNodeId, string? Comment, string OperatorUser, string? ApiKeyId = null);