feat(galaxy): #1074 secured writes over gRPC data connections are a separate opt-in, default off
- WriteCaller gains an additive Origin (WriteCallerOrigin: Unspecified (default) | OpcUaSession | DataConnection), stamped by the runtime at the receiving seam: OtOpcUaNodeManager -> OpcUaSession, the rich (gRPC data-connection) write path -> DataConnection. Never parsed from the principal/key. - New driver-config option MxAccess.SecuredWritesOverDataConnections (default false; factory key mxAccess.securedWritesOverDataConnections; AdminUI "Also for gRPC data-connection writes", owned path). The Galaxy driver gives a caller an identity source only in ApiKeyIdentity mode AND for an allowed origin: OpcUaSession always, DataConnection only with the option, Unspecified never (fail closed). Off => a secured write over a data connection is refused exactly as before #1074 (local BadUserAccessDenied, no identity lookup; the gRPC caller sees the same OutcomeUnknown as before). - Tests: option off refuses a gRPC write end to end into the real GalaxyDriver (with an OPC UA positive control on the same driver); option-on end-to-end kept; driver-level origin matrix incl. Unspecified; factory binding; AdminUI round-trip; node-manager callers now carry OpcUaSession. - Docs: Galaxy.md (origin table, opt-in, forwarded-write delegation caveat, live-gate leg), security.md, DataConnections.md, Configuration.md, rules/drivers.md.
This commit is contained in:
+16
@@ -112,6 +112,18 @@
|
||||
<code>VerifiedWrite</code> attributes are always refused.
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-check form-switch mt-4">
|
||||
<InputCheckbox aria-describedby="@FieldIds("field-11b-hint")" @bind-Value="_form.Galaxy.MxSecuredWritesOverDataConnections" @bind-Value:after="EmitAsync" class="form-check-input" id="@FieldId("field-11b")" disabled="@(_form.Galaxy.MxSecuredWrites != GalaxySecuredWriteMode.ApiKeyIdentity)" />
|
||||
<label class="form-check-label" for="@FieldId("field-11b")">Also for gRPC data-connection writes</label>
|
||||
</div>
|
||||
<div id="@FieldId("field-11b-hint")" class="form-text">
|
||||
Off (default): a secured write arriving over a data connection is refused, and only OPC UA sessions write
|
||||
as their key's identity (#1074). On: it runs as the <em>connection's</em> key. A consumer cluster forwarding
|
||||
its own clients' writes presents its link's service key, so every client allowed to write the projected
|
||||
node would write secured attributes as that key's Galaxy identity.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -254,6 +266,7 @@
|
||||
"gateway.keepAlivePingDelaySeconds", "gateway.keepAlivePingTimeoutSeconds",
|
||||
"mxAccess.clientName", "mxAccess.publishingIntervalMs", "mxAccess.writeUserId", "mxAccess.eventPumpChannelCapacity",
|
||||
"mxAccess.securedWrites",
|
||||
"mxAccess.securedWritesOverDataConnections",
|
||||
"repository.discoverPageSize", "repository.watchDeployEvents",
|
||||
"reconnect.initialBackoffMs", "reconnect.maxBackoffMs", "reconnect.replayOnSessionLost",
|
||||
"probeTimeoutSeconds",
|
||||
@@ -334,6 +347,7 @@
|
||||
public int MxWriteUserId { get; set; } = 0;
|
||||
public int MxEventPumpChannelCapacity { get; set; } = 50_000;
|
||||
public GalaxySecuredWriteMode MxSecuredWrites { get; set; } = GalaxySecuredWriteMode.Refuse;
|
||||
public bool MxSecuredWritesOverDataConnections { get; set; }
|
||||
|
||||
// GalaxyRepositoryOptions
|
||||
public int RepositoryDiscoverPageSize { get; set; } = 5000;
|
||||
@@ -376,6 +390,7 @@
|
||||
MxWriteUserId = mx.WriteUserId,
|
||||
MxEventPumpChannelCapacity = mx.EventPumpChannelCapacity,
|
||||
MxSecuredWrites = mx.SecuredWrites,
|
||||
MxSecuredWritesOverDataConnections = mx.SecuredWritesOverDataConnections,
|
||||
RepositoryDiscoverPageSize = repo.DiscoverPageSize,
|
||||
RepositoryWatchDeployEvents = repo.WatchDeployEvents,
|
||||
ReconnectInitialBackoffMs = rc.InitialBackoffMs,
|
||||
@@ -407,6 +422,7 @@
|
||||
EventPumpChannelCapacity: MxEventPumpChannelCapacity)
|
||||
{
|
||||
SecuredWrites = MxSecuredWrites,
|
||||
SecuredWritesOverDataConnections = MxSecuredWritesOverDataConnections,
|
||||
},
|
||||
Repository: new GalaxyRepositoryOptions(
|
||||
DiscoverPageSize: RepositoryDiscoverPageSize,
|
||||
|
||||
@@ -3559,7 +3559,8 @@ public sealed partial class OtOpcUaNodeManager : CustomNodeManager2, INodeManage
|
||||
return DispatchDeviceWrite(gateway, nodeKey, nodeBareId, nodeRealm, optimisticValue, priorValue, priorStatus, clientUserId,
|
||||
(node as EquipmentVariableState)?.ActiveWriteStamp,
|
||||
// #1017: WHO wrote rides to the driver, so a per-user device permission (Galaxy SecuredWrite) can act on it.
|
||||
identity is null ? null : new WriteCaller(identity.Principal.Length > 0 ? identity.Principal : null, identity.ApiKeyId));
|
||||
identity is null ? null : new WriteCaller(identity.Principal.Length > 0 ? identity.Principal : null, identity.ApiKeyId,
|
||||
WriteCallerOrigin.OpcUaSession));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1580,11 +1580,14 @@ public sealed class DriverInstanceActor : ReceiveActor, IWithTimers
|
||||
/// <summary>
|
||||
/// #1074 — who issued a gRPC data-connection write, in the same shape the OPC UA node manager builds for a
|
||||
/// session (#1017): the admitted principal and the public id of the API key the connection authenticated with.
|
||||
/// Both are mandatory on an admission (<see cref="DataWriteAdmission.Validate"/>) and carry no secret.
|
||||
/// Both are mandatory on an admission (<see cref="DataWriteAdmission.Validate"/>) and carry no secret. Marked
|
||||
/// <see cref="WriteCallerOrigin.DataConnection"/> so a driver can hold this plane to its own opt-in (Galaxy
|
||||
/// <c>MxAccess.SecuredWritesOverDataConnections</c>, default off).
|
||||
/// </summary>
|
||||
internal static WriteCaller RichCaller(DataWriteAdmission admission) =>
|
||||
new(string.IsNullOrWhiteSpace(admission.PrincipalId) ? null : admission.PrincipalId,
|
||||
string.IsNullOrWhiteSpace(admission.ApiKeyId) ? null : admission.ApiKeyId);
|
||||
string.IsNullOrWhiteSpace(admission.ApiKeyId) ? null : admission.ApiKeyId,
|
||||
WriteCallerOrigin.DataConnection);
|
||||
|
||||
private static async Task ObserveRichDriver(Task<IReadOnlyList<DataWriteOutcome>> task,
|
||||
TaskCompletionSource<DataWriteOutcome> physical)
|
||||
|
||||
Reference in New Issue
Block a user