feat(grpc-data): #1084 secured writes over a data connection need an export-level opt-in; #1091 Galaxy reports gRPC write outcomes definitively

#1084 - DataExport.AllowSecuredWrites (default false; migration AddDataExportAllowSecuredWrites, a bit NOT NULL DEFAULT 0
column, no constraint => no MigrationPreChecks twin; the preflight's legacy-schema tolerance covers the missing column).
- Valid only with Write: validator code DataExportSecuredWriteInvalid at authoring, the deploy gate and on a deployed
  row (an artifact row breaking it fails closed), modelled on AllowGalaxyServiceAck.
- LocalExportCatalog keeps it per rule (counts only with Write) and answers AllowsSecuredWrite(principal, node): an
  export of the principal, in the node's realm, granting Write, opted in, whose root contains the node.
- DataWriteExecutor stamps DataWriteAdmission.AllowsSecuredWrite (new, default false) from the catalog generation that
  admitted the write (re-checked by the dispatch gate's commit), never from the request.
- DriverInstanceActor.RichCaller returns null without it, so the driver gets NO caller: the driver option
  MxAccess.SecuredWritesOverDataConnections alone no longer lets a forwarding consumer cluster's link key write
  SecuredWrite attributes. Fail closed by default.
- AdminUI export editor: "Allow secured writes under this peer's key identity" checkbox (enabled only with Write).

#1091 (a) - GalaxyDriver implements IWriteOutcomeCapability + ICallerAwareWriteOutcomeCapability. GalaxyWriteOutcomes
maps BadUserAccessDenied and the OnWriteComplete verdicts BadNotWritable/BadTypeMismatch/BadOutOfRange/
BadConfigurationError to DriverConfirmedFailure, Good to AcceptedUnconfirmed (a provisional Good is indistinguishable),
everything else to OutcomeUnknown. A refused secured write is now a definite BadUserAccessDenied, not OutcomeUnknown.
- RunRichWriteAsync precedence: caller-aware outcome overload (caller present) -> outcome overload -> ICallerAwareWritable
  (caller present) -> IWritable. Both earlier behaviours kept; the OPC UA path is unchanged.

Tests (each failed before its fix where applicable):
- End to end through the runtime path (artifact -> catalog -> DataWriteRuntime executor -> ActorDataWriteRoute ->
  DriverInstanceActor behind the real dispatch gate -> real GalaxyDriver): export opt-in x driver option matrix; only
  both commit as the key's identity, either alone refuses BadUserAccessDenied definitively with no identity lookup.
  Ignoring the flag in RichCaller fails 3 tests.
- Catalog scope (root containment, Write, principal), artifact round-trip + fail-closed row, validator, migration SQL +
  no pending model changes, AdminUI checkbox enable/save (bUnit), actor precedence, Galaxy outcome mapping.
- ScriptForeignKeysAndExternalIdUniquenessMigrationTests now migrate to THEIR migration, not the latest.

Docs: DataConnections.md (two-gate table), Galaxy.md, security.md, rules/drivers.md.
This commit is contained in:
Joseph Doherty
2026-12-04 14:58:16 -05:00
parent 2f22003061
commit 8e2a793000
23 changed files with 2704 additions and 53 deletions
@@ -31,5 +31,13 @@ public sealed class DataExport
/// <summary>A2 (used by A2b): per-export opt-in for remote acknowledgement of Galaxy conditions, which execute as the
/// origin's service identity (plan §5.6, Q2). Valid only with <c>AlarmAcknowledge</c>.</summary>
public bool AllowGalaxyServiceAck { get; set; }
/// <summary>
/// #1084: per-export opt-in for writes that act under the connection key's own identity (Galaxy SecuredWrite attributes,
/// written as the key's <c>/api-keys</c> Galaxy account). Without it the origin hands the driver NO caller for a write
/// admitted through this export, so a caller-aware driver refuses an identity-bearing write exactly as it would an
/// anonymous one — even with the driver's own <c>MxAccess.SecuredWritesOverDataConnections</c> on. Both are needed.
/// Valid only with <c>Write</c>. Default false (fail closed).
/// </summary>
public bool AllowSecuredWrites { get; set; }
public byte[] RowVersion { get; set; } = [];
}
@@ -0,0 +1,32 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ZB.MOM.WW.OtOpcUa.Configuration.Migrations
{
/// <inheritdoc />
public partial class AddDataExportAllowSecuredWrites : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
// #1084: the export-level opt-in for secured (caller-identity) writes over a data connection. Non-null with a
// false default, so every existing export keeps refusing them and no row needs a backfill. No check constraint:
// "only with Write" is a validator rule (DataExportSecuredWriteInvalid), like AllowGalaxyServiceAck's.
migrationBuilder.AddColumn<bool>(
name: "AllowSecuredWrites",
table: "DataExport",
type: "bit",
nullable: false,
defaultValue: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "AllowSecuredWrites",
table: "DataExport");
}
}
}
@@ -500,6 +500,9 @@ namespace ZB.MOM.WW.OtOpcUa.Configuration.Migrations
b.Property<bool>("AllowGalaxyServiceAck")
.HasColumnType("bit");
b.Property<bool>("AllowSecuredWrites")
.HasColumnType("bit");
b.Property<int>("AllowedOperations")
.HasColumnType("int");
@@ -349,6 +349,10 @@ public static class DataConnectionValidator
// must stay false; a deployed row from a newer central that carries both is tolerated (the flag is inert here).
if (export.AllowGalaxyServiceAck && !export.AllowedOperations.HasFlag(DataOperations.AlarmAcknowledge))
Add("DataExportGalaxyAckInvalid", id, "Galaxy service acknowledgement can be allowed only on an export that grants AlarmAcknowledge.");
// #1084: the secured-write (caller-identity) opt-in qualifies the Write grant and means nothing without it. Checked
// at authoring, at the deploy gate and on a deployed row alike (a deployed row breaking it fails closed).
if (export.AllowSecuredWrites && !export.AllowedOperations.HasFlag(DataOperations.Write))
Add("DataExportSecuredWriteInvalid", id, "Secured writes can be allowed only on an export that grants Write.");
// #942: an alarm-bearing tag is never a value (#917: an unsupported value node, hidden from Browse; #896: no UNS
// variable), and its condition placements sit under the tag's folder / the referencing equipment, never under the
// tag. So an export rooted at the tag (RawTag) grants nothing at all, and one rooted at a reference to it
@@ -29,10 +29,16 @@ public sealed record WriteItem(string CorrelationId, string OperationId, DataVie
/// recheck the original key's current principal and credential version against authority and its
/// original expiry even when the epoch is unchanged. ApiKeyId and CredentialVersion are non-secret
/// identifiers, never the bearer credential.
/// <para>
/// <paramref name="AllowsSecuredWrite"/> (#1084): whether an export covering the node opts in to secured (caller-identity)
/// writes (<c>DataExport.AllowSecuredWrites</c>). Only then does the runtime hand the driver the connection's caller; false
/// (the default — fail closed) dispatches the write with no caller, so a caller-aware driver refuses an identity-bearing
/// write exactly as it would an anonymous one.
/// </para>
/// </summary>
public sealed record DataWriteAdmission(string PrincipalId, DataView View, long AuthorityEpoch, long CatalogRevision,
string ServingIncarnation, string DriverIncarnation, string OperationId, long MonotonicExpiry,
string ApiKeyId, DateTimeOffset? CredentialExpiresUtc, string CredentialVersion)
string ApiKeyId, DateTimeOffset? CredentialExpiresUtc, string CredentialVersion, bool AllowsSecuredWrite = false)
{
public void Validate()
{
@@ -39,8 +39,9 @@ public enum WriteCallerOrigin
/// attributes, written under the calling API key's Galaxy account). The runtime calls this overload instead
/// of <see cref="IWritable.WriteAsync" /> whenever the write carries a <see cref="WriteCaller" />. Both data planes
/// supply one: an OPC UA write from its session, a gRPC data-connection write from the connection's authenticated
/// key (#1074) — except through <c>IWriteOutcomeCapability</c>, which takes precedence on the gRPC path and carries
/// no caller. It must keep
/// key (#1074), and only when the origin export opts in (<c>DataExport.AllowSecuredWrites</c>, #1084). On the gRPC path
/// a driver that also implements <c>IWriteOutcomeCapability</c> is called through that instead — with a caller, through
/// <c>ICallerAwareWriteOutcomeCapability</c> (#1091). It must keep
/// every other behaviour of <see cref="IWritable.WriteAsync" />; a caller the driver cannot map is refused
/// per write (e.g. <c>BadUserAccessDenied</c>), never silently written under another identity.
/// </summary>
@@ -4,6 +4,7 @@ using Microsoft.Extensions.Logging.Abstractions;
using ZB.MOM.WW.MxGateway.Client;
using ZB.MOM.WW.MxGateway.Contracts.Proto;
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
using ZB.MOM.WW.OtOpcUa.Core.Abstractions.DataConnections;
using ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Browse;
using ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Config;
using ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Health;
@@ -38,7 +39,7 @@ namespace ZB.MOM.WW.OtOpcUa.Driver.Galaxy;
/// </para>
/// </remarks>
public sealed class GalaxyDriver
: IDriver, ITagDiscovery, IReadable, IWritable, ICallerAwareWritable, ISubscribable, IRediscoverable, IHostConnectivityProbe, IAlarmSource, IAlarmInitialStateSignal, IAlarmAcknowledgePreflight, IAlarmAcknowledgeConfirmation, ISkippedTagReporter, IDisposable, IAsyncDisposable
: IDriver, ITagDiscovery, IReadable, IWritable, ICallerAwareWritable, ICallerAwareWriteOutcomeCapability, ISubscribable, IRediscoverable, IHostConnectivityProbe, IAlarmSource, IAlarmInitialStateSignal, IAlarmAcknowledgePreflight, IAlarmAcknowledgeConfirmation, ISkippedTagReporter, IDisposable, IAsyncDisposable
{
/// <summary>Authored tags this driver could not dial — a TagConfig with no usable
/// <c>attributeRef</c> has no MXAccess address to bind.</summary>
@@ -2438,6 +2439,42 @@ public sealed class GalaxyDriver
dialledWrites, attributeRef => ResolveSecurity(ToRawPath(attributeRef)), securedCredential, cancellationToken);
}
// ===== IWriteOutcomeCapability (#1091) — the gRPC data-connection write path =====
/// <summary>
/// #1091 — <see cref="WriteAsync(IReadOnlyList{WriteRequest}, CancellationToken)"/> reported as explicit outcomes for
/// the gRPC data-connection write path (<see cref="GalaxyWriteOutcomes.From"/>): a refusal is a definite
/// <see cref="DataWriteState.DriverConfirmedFailure"/> carrying its status (a refused secured write ⇒
/// <c>BadUserAccessDenied</c>), where the legacy path reported every non-Good result as <c>OutcomeUnknown</c>.
/// </summary>
/// <param name="writes">Pairs of full reference (RawPath) + value.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>One outcome per request, in order.</returns>
public Task<IReadOnlyList<DataWriteOutcome>> WriteWithOutcomesAsync(
IReadOnlyList<WriteRequest> writes, CancellationToken cancellationToken)
=> WithOutcomesAsync(writes, caller: null, cancellationToken);
/// <summary>
/// #1091 — <see cref="WriteAsync(IReadOnlyList{WriteRequest}, WriteCaller, CancellationToken)"/> (the caller's Galaxy
/// identity for SecuredWrite attributes, under the same origin rules) reported as explicit outcomes.
/// </summary>
/// <param name="writes">Pairs of full reference (RawPath) + value.</param>
/// <param name="caller">Who issued the write.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>One outcome per request, in order.</returns>
public Task<IReadOnlyList<DataWriteOutcome>> WriteWithOutcomesAsync(
IReadOnlyList<WriteRequest> writes, WriteCaller caller, CancellationToken cancellationToken)
=> WithOutcomesAsync(writes, caller ?? throw new ArgumentNullException(nameof(caller)), cancellationToken);
private async Task<IReadOnlyList<DataWriteOutcome>> WithOutcomesAsync(
IReadOnlyList<WriteRequest> writes, WriteCaller? caller, CancellationToken cancellationToken)
{
var results = await WriteCoreAsync(writes, caller, cancellationToken).ConfigureAwait(false);
var outcomes = new DataWriteOutcome[results.Count];
for (var i = 0; i < results.Count; i++) outcomes[i] = GalaxyWriteOutcomes.From(results[i]);
return outcomes;
}
/// <summary>
/// #1074 — which data planes a SecuredWrite may run under the caller's identity on. An OPC UA session always
/// (the #1017 opt-in alone); a gRPC data connection only with <c>MxAccess.SecuredWritesOverDataConnections</c>
@@ -0,0 +1,47 @@
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
using ZB.MOM.WW.OtOpcUa.Core.Abstractions.DataConnections;
namespace ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Runtime;
/// <summary>
/// #1091 — how a Galaxy <see cref="WriteResult"/> reads as a gRPC data-connection <see cref="DataWriteOutcome"/>. Only a
/// status that can arise solely from a definite verdict is reported as one; everything ambiguous stays
/// <see cref="DataWriteState.OutcomeUnknown"/>, because a caller treats a definite failure as "the value did not change".
/// </summary>
/// <remarks>
/// <list type="bullet">
/// <item><b>Good</b> ⇒ <see cref="DataWriteState.AcceptedUnconfirmed"/> (as the legacy path reported it): the writer
/// reports a provisional Good off an EMPTY gateway statuses array (the completion wait timed out), which the result
/// cannot tell apart from a confirmed one.</item>
/// <item><b>Definite refusals</b> ⇒ <see cref="DataWriteState.DriverConfirmedFailure"/> with the status:
/// <c>BadUserAccessDenied</c> — a local secured/verified-write refusal (no identity, origin not allowed, identity
/// unresolvable), a failed <c>AuthenticateUser</c> (no <c>WriteSecured</c> sent), the gateway refusing the caller
/// (<c>PermissionDenied</c>/<c>Unauthenticated</c>, nothing executed) or MXAccess's own access verdict (1008/1012/
/// 1013/1016/1017); and the MXAccess <c>OnWriteComplete</c> verdicts <c>BadNotWritable</c>, <c>BadTypeMismatch</c>,
/// <c>BadOutOfRange</c> and <c>BadConfigurationError</c>, which no transport/exception path of the writer produces.</item>
/// <item><b>Everything else</b> ⇒ <see cref="DataWriteState.OutcomeUnknown"/> with the status:
/// <c>BadCommunicationError</c> (protocol failure, exception, failed advise), <c>BadTimeout</c>, Uncertain
/// (Pending/Warning), <c>BadInternalError</c>, generic Bad and any other code.</item>
/// </list>
/// </remarks>
internal static class GalaxyWriteOutcomes
{
/// <summary>Maps one write result.</summary>
/// <param name="result">The writer's result.</param>
/// <returns>The data-connection outcome.</returns>
public static DataWriteOutcome From(WriteResult result)
{
ArgumentNullException.ThrowIfNull(result);
var status = result.StatusCode;
if (status == StatusCodeMap.Good) return new(DataWriteState.AcceptedUnconfirmed, status, null);
return status switch
{
StatusCodeMap.BadUserAccessDenied => new(DataWriteState.DriverConfirmedFailure, status, "Write refused: access denied."),
StatusCodeMap.BadNotWritable => new(DataWriteState.DriverConfirmedFailure, status, "Write refused: not writable."),
StatusCodeMap.BadTypeMismatch => new(DataWriteState.DriverConfirmedFailure, status, "Write refused: type mismatch."),
StatusCodeMap.BadOutOfRange => new(DataWriteState.DriverConfirmedFailure, status, "Write refused: out of range."),
StatusCodeMap.BadConfigurationError => new(DataWriteState.DriverConfirmedFailure, status, "Write refused: configuration error."),
_ => new(DataWriteState.OutcomeUnknown, status, "Write outcome unknown."),
};
}
}
@@ -123,6 +123,7 @@ else
<label class="form-label" for="export-history-bytes">History response bytes</label><input id="export-history-bytes" type="number" min="@DataConnectionValidator.MinHistoryResponseBytesLimit" max="@DataConnectionValidator.MaxHistoryResponseBytesLimit" class="form-control mb-2" @bind="e.MaxHistoryResponseBytes" /><div class="form-text">Larger answers are sent in bounded chunks.</div>
<label class="form-label" for="export-max-conditions">Conditions per alarm subscription</label><input id="export-max-conditions" type="number" min="1" max="@DataConnectionValidator.MaxConditionsLimit" class="form-control mb-2" @bind="e.MaxConditions" /><div class="form-text">A remote AlarmSubscribe scope with more conditions than this is refused (ConditionCapacity) before anything is imported.</div>
<label class="d-block"><input id="export-galaxy-ack" type="checkbox" @bind="e.AllowGalaxyServiceAck" disabled="@(!e.AllowedOperations.HasFlag(DataOperations.AlarmAcknowledge) && !e.AllowGalaxyServiceAck)" /> Allow remote acknowledge of Galaxy alarms</label><div class="form-text">Galaxy-sourced alarms are acknowledged under this peer's API-key Galaxy ack identity (provision <code>otopcua/apikeys/&lt;keyId&gt;/galaxy-ack-user</code> and <code>…/galaxy-ack-password</code> on this cluster). Requires AlarmAcknowledge.</div>
<label class="d-block"><input id="export-secured-writes" type="checkbox" @bind="e.AllowSecuredWrites" disabled="@(!e.AllowedOperations.HasFlag(DataOperations.Write) && !e.AllowSecuredWrites)" /> Allow secured writes under this peer's key identity</label><div class="form-text">Galaxy SecuredWrite attributes written through this export run as this peer's API-key Galaxy identity (the same <code>otopcua/apikeys/&lt;keyId&gt;/galaxy-ack-*</code> secrets). Also needs the Galaxy driver's "Also for gRPC data-connection writes". If the peer is another OtOpcUa cluster, every client it forwards writes for writes as that one identity. Requires Write.</div>
<label><input type="checkbox" @bind="e.Enabled" /> Enabled in next deployment</label>@Actions(e, e.DataExportRowId != Guid.Empty)
</div></section>
}
@@ -144,7 +144,10 @@ internal sealed class DataWriteExecutor(DataAuthenticatedContext context, Func<L
var issued = clock.GetTimestamp();
var admission = new DataWriteAdmission(context.PrincipalId, node.Metadata.View, current.AuthorityEpoch,
current.Serving.CatalogEpoch, current.Serving.Incarnation, target.DriverIncarnation, item.OperationId,
expiration, context.ApiKeyId, context.CredentialExpiresUtc, context.CredentialVersion);
expiration, context.ApiKeyId, context.CredentialExpiresUtc, context.CredentialVersion,
// #1084: decided here, from the same catalog generation that admitted the write (the dispatch gate's commit
// re-checks that generation), never from the request.
AllowsSecuredWrite: current.AllowsSecuredWrite(context.PrincipalId, node));
var scope = new FrozenWriteScope(node.Scope.ClusterId, node.Scope.Kind, node.Scope.Segments.ToImmutableArray());
var proof = new WriteRouteProof(admission, scope, node.EntityKind, node.EntityId, node.Source,
target.DriverInstanceId, target.DriverReference, target.RouteGeneration, target.PrimaryGeneration, current.Serving);
@@ -22,7 +22,7 @@ public sealed partial class LocalExportCatalog
private sealed record ExportRule(string Identity, string Principal, DataRealm Realm, DataView? Root, bool WholeRealm,
DataOperations Operations, int Batch, int Page, int Items, int Streams,
int HistoryReads = 4, int HistoryValuesPerPage = 10_000, int HistoryResponseBytes = 4 * 1024 * 1024,
int Conditions = 1000, bool GalaxyServiceAck = false);
int Conditions = 1000, bool GalaxyServiceAck = false, bool SecuredWrites = false);
public LocalExportCatalog(string clusterId, ServingIdentity serving, IDataMappedCatalogAuthority activation,
IEnumerable<LocalDataNode> nodes, IEnumerable<DataExport> exports, int maximumNodes = 100_000,
@@ -100,7 +100,9 @@ public sealed partial class LocalExportCatalog
export.AllowedOperations & DataOperationSets.Understood, export.MaxBatchItems, export.MaxPageItems, export.MaxMonitoredItems, export.MaxStreams,
export.MaxConcurrentHistoryReads, export.MaxHistoryValuesPerPage, export.MaxHistoryResponseBytes, export.MaxConditions,
// A2b (§6, Q2): the Galaxy service-ack opt-in counts only with the AlarmAcknowledge grant it qualifies.
export.AllowGalaxyServiceAck && (export.AllowedOperations & DataOperations.AlarmAcknowledge) != 0));
export.AllowGalaxyServiceAck && (export.AllowedOperations & DataOperations.AlarmAcknowledge) != 0,
// #1084: the secured-write (caller-identity) opt-in counts only with the Write grant it qualifies.
export.AllowSecuredWrites && (export.AllowedOperations & DataOperations.Write) != 0));
if (UnknownOperationDrops.Unknown(export.AllowedOperations) is var unknown && unknown != DataOperations.None)
dropped[export.DataExportId] = unknown;
}
@@ -201,6 +203,25 @@ public sealed partial class LocalExportCatalog
return false;
}
/// <summary>
/// #1084: whether <paramref name="principal"/> holds an export of the node's realm that grants Write on it AND opts in to
/// secured writes (<c>DataExport.AllowSecuredWrites</c>) — i.e. a write admitted for this node may carry the connection's
/// caller to a caller-aware driver (Galaxy SecuredWrite under the key's Galaxy identity). Any one such export suffices,
/// exactly as for <see cref="AllowsExport"/>; with none the write is still admitted (on the Write grant) but goes to the
/// driver without a caller, so an identity-bearing write is refused there.
/// </summary>
internal bool AllowsSecuredWrite(string principal, LocalDataNode node)
{
ArgumentNullException.ThrowIfNull(node);
foreach (var rule in _exports)
{
if (!rule.SecuredWrites || !string.Equals(principal, rule.Principal, StringComparison.OrdinalIgnoreCase)
|| rule.Realm != node.Metadata.View.Realm || (rule.Operations & DataOperations.Write) == 0) continue;
if (rule.WholeRealm || IsAncestor(rule.Root!, node.Metadata.View)) return true;
}
return false;
}
internal string SubscriptionExportScope(string principal, LocalDataNode node)
{
var ids = _exports.Where(rule => string.Equals(principal, rule.Principal, StringComparison.OrdinalIgnoreCase) &&
@@ -1510,14 +1510,18 @@ public sealed class DriverInstanceActor : ReceiveActor, IWithTimers
{
// #1074: a gRPC data-connection write carries its caller like an OPC UA write does (#1017) —
// the admission's principal + API key id, bound from the authenticated transport context
// (never from the request payload) and re-checked by the dispatch gate's commit above. A
// caller-aware driver (Galaxy SecuredWrite under the key's Galaxy identity) gets it; every
// other driver is unchanged. No driver is both IWriteOutcomeCapability and
// ICallerAwareWritable today; one that were would need a caller-aware outcome overload.
if (driver is IWriteOutcomeCapability rich)
// (never from the request payload) and re-checked by the dispatch gate's commit above. #1084:
// only when an export covering the node opts in (AllowsSecuredWrite); otherwise there is no
// caller and a caller-aware driver gets the caller-less call (identity-bearing writes refused).
// Precedence (#1091): the explicit-outcome path wins over the legacy one, and within each the
// caller-aware overload is used whenever there is a caller.
var caller = RichCaller(msg.Ticket.Proof.Admission);
if (caller is not null && driver is ICallerAwareWriteOutcomeCapability richCaller)
_ = ObserveRichDriver(richCaller.WriteWithOutcomesAsync(request, caller, ct), physical);
else if (driver is IWriteOutcomeCapability rich)
_ = ObserveRichDriver(rich.WriteWithOutcomesAsync(request, ct), physical);
else if (driver is ICallerAwareWritable callerAware)
_ = ObserveLegacyDriver(callerAware.WriteAsync(request, RichCaller(msg.Ticket.Proof.Admission), ct), physical);
else if (caller is not null && driver is ICallerAwareWritable callerAware)
_ = ObserveLegacyDriver(callerAware.WriteAsync(request, caller, ct), physical);
else
_ = ObserveLegacyDriver(((IWritable)driver).WriteAsync(request, ct), physical);
}
@@ -1583,11 +1587,17 @@ public sealed class DriverInstanceActor : ReceiveActor, IWithTimers
/// 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).
/// <para>
/// #1084: null unless the admission says an export covering the node opts in to secured writes
/// (<c>DataExport.AllowSecuredWrites</c>, default off). The driver option alone is therefore not enough: a
/// forwarding consumer cluster's link gets no caller identity unless the origin's export for it says so.
/// </para>
/// </summary>
internal static WriteCaller RichCaller(DataWriteAdmission admission) =>
new(string.IsNullOrWhiteSpace(admission.PrincipalId) ? null : admission.PrincipalId,
string.IsNullOrWhiteSpace(admission.ApiKeyId) ? null : admission.ApiKeyId,
WriteCallerOrigin.DataConnection);
internal static WriteCaller? RichCaller(DataWriteAdmission admission) =>
!admission.AllowsSecuredWrite ? null
: new(string.IsNullOrWhiteSpace(admission.PrincipalId) ? null : admission.PrincipalId,
string.IsNullOrWhiteSpace(admission.ApiKeyId) ? null : admission.ApiKeyId,
WriteCallerOrigin.DataConnection);
private static async Task ObserveRichDriver(Task<IReadOnlyList<DataWriteOutcome>> task,
TaskCompletionSource<DataWriteOutcome> physical)