Merge Galaxy/AdminUI/Client follow-ups: opt-in SecuredWrite under the caller's API-key Galaxy identity, VerifiedWrite still refused (#1017), Galaxy form keeps KeepAlive keys (#1045), explicit empty ack password (#1050), Client.UI batched recursive subscribe + CLI --reconnect-timeout exit 3 (#1048)
This commit is contained in:
@@ -35,6 +35,19 @@ public interface IApiKeyGalaxyAckIdentityService
|
||||
/// <returns>A task representing the operation.</returns>
|
||||
Task SetAsync(string apiKeyId, string user, string? domain, string? password, string actor, CancellationToken ct);
|
||||
|
||||
/// <summary>
|
||||
/// Sets (or replaces) a key's Galaxy ack identity with an EMPTY password (#1050). Galaxy accounts can have
|
||||
/// empty passwords, but <see cref="SetAsync"/> reads a blank password as "keep the stored one" (and refuses it
|
||||
/// first time), so storing an empty password needs this explicit call.
|
||||
/// </summary>
|
||||
/// <param name="apiKeyId">The public key id.</param>
|
||||
/// <param name="user">Galaxy user; required.</param>
|
||||
/// <param name="domain">Optional domain.</param>
|
||||
/// <param name="actor">The admin performing the change, for audit.</param>
|
||||
/// <param name="ct">The cancellation token.</param>
|
||||
/// <returns>A task representing the operation.</returns>
|
||||
Task SetWithEmptyPasswordAsync(string apiKeyId, string user, string? domain, string actor, CancellationToken ct);
|
||||
|
||||
/// <summary>Removes a key's Galaxy ack identity (no-op when none).</summary>
|
||||
/// <param name="apiKeyId">The public key id.</param>
|
||||
/// <param name="actor">The admin performing the change, for audit.</param>
|
||||
@@ -97,8 +110,16 @@ public sealed class ApiKeyGalaxyAckIdentityService : IApiKeyGalaxyAckIdentitySer
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task SetAsync(
|
||||
public Task SetAsync(
|
||||
string apiKeyId, string user, string? domain, string? password, string actor, CancellationToken ct)
|
||||
=> SetCoreAsync(apiKeyId, user, domain, password, emptyPassword: false, actor, ct);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task SetWithEmptyPasswordAsync(string apiKeyId, string user, string? domain, string actor, CancellationToken ct)
|
||||
=> SetCoreAsync(apiKeyId, user, domain, password: null, emptyPassword: true, actor, ct);
|
||||
|
||||
private async Task SetCoreAsync(
|
||||
string apiKeyId, string user, string? domain, string? password, bool emptyPassword, string actor, CancellationToken ct)
|
||||
{
|
||||
user = (user ?? string.Empty).Trim();
|
||||
if (user.Length == 0) throw new ArgumentException("A Galaxy user is required.", nameof(user));
|
||||
@@ -108,14 +129,23 @@ public sealed class ApiKeyGalaxyAckIdentityService : IApiKeyGalaxyAckIdentitySer
|
||||
var userName = new SecretName(GalaxyAckIdentitySecrets.UserSecretName(apiKeyId));
|
||||
var passwordName = new SecretName(GalaxyAckIdentitySecrets.PasswordSecretName(apiKeyId));
|
||||
|
||||
if (string.IsNullOrEmpty(password))
|
||||
if (emptyPassword)
|
||||
{
|
||||
// #1050: the explicit "this account has an empty password" option. Written like any new password —
|
||||
// password FIRST, so a concurrent ack never pairs the new user with a missing password.
|
||||
await UpsertAsync(passwordName, string.Empty, $"Galaxy ack password (empty) for API key {apiKeyId}", actor, ct)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
else if (string.IsNullOrEmpty(password))
|
||||
{
|
||||
// The editor never renders a stored password back, so a blank box means "keep the current one" -
|
||||
// overwriting it with an empty value would silently break every ack on this key (#997 A-4). With no
|
||||
// existing identity there is nothing to keep, so a blank password is refused instead (as is a half-configured identity whose password secret is gone).
|
||||
var existing = await _store.GetAsync(passwordName, ct).ConfigureAwait(false);
|
||||
if (existing is null || existing.IsDeleted)
|
||||
throw new ArgumentException("A password is required when setting a Galaxy ack identity.", nameof(password));
|
||||
throw new ArgumentException(
|
||||
"A password is required when setting a Galaxy ack identity (for an account whose password is empty, " +
|
||||
"tick \"Empty password\").", nameof(password));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -64,6 +64,8 @@
|
||||
the Historian records it as the operator. Stored encrypted in the Secrets store
|
||||
(<span class="mono">otopcua/apikeys/@(_ackEditKeyId)/galaxy-ack-*</span>), never in the database. Keys
|
||||
without an identity use the Galaxy driver's fallback account; with neither, acknowledges are refused.
|
||||
A Galaxy driver set to <em>Secured writes = API key identity</em> also writes <code>SecuredWrite</code>
|
||||
attributes as this account (#1017) — with no fallback: a key without an identity cannot make secured writes.
|
||||
On a split admin/driver topology the two secrets must also exist on the driver nodes.
|
||||
</div>
|
||||
<div class="row g-2">
|
||||
@@ -78,8 +80,13 @@
|
||||
<div class="col-md-3">
|
||||
<label class="form-label" for="ack-password">Password</label>
|
||||
<input id="ack-password" type="password" class="form-control form-control-sm" @bind="_ackPassword"
|
||||
placeholder="@(_ackIdentities.ContainsKey(_ackEditKeyId) ? "leave blank to keep the current password" : null)"
|
||||
autocomplete="new-password" />
|
||||
placeholder="@(_ackEmptyPassword ? "(empty password)" : _ackIdentities.ContainsKey(_ackEditKeyId) ? "leave blank to keep the current password" : null)"
|
||||
disabled="@_ackEmptyPassword" autocomplete="new-password" />
|
||||
<div class="form-check mt-1">
|
||||
<input id="ack-empty-password" type="checkbox" class="form-check-input" @bind="_ackEmptyPassword" @bind:after="OnAckEmptyPasswordChanged" />
|
||||
<label class="form-check-label" for="ack-empty-password">Empty password</label>
|
||||
</div>
|
||||
<div class="form-text">The account's password is genuinely empty (a blank box keeps the stored password).</div>
|
||||
</div>
|
||||
<div class="col-md-3 d-flex align-items-end gap-2">
|
||||
<button class="btn btn-sm btn-primary" @onclick="SaveAckIdentityAsync" disabled="@_busy">Save</button>
|
||||
@@ -191,6 +198,8 @@
|
||||
private string _ackUser = "";
|
||||
private string _ackDomain = "";
|
||||
private string _ackPassword = "";
|
||||
// #1050: explicit "the account's password is empty" — a blank box alone means "keep the stored password".
|
||||
private bool _ackEmptyPassword;
|
||||
private string _newName = "";
|
||||
private string _newPrincipal = "";
|
||||
private DateTime? _newExpires;
|
||||
@@ -320,6 +329,7 @@
|
||||
{
|
||||
_ackEditKeyId = apiKeyId;
|
||||
_ackPassword = "";
|
||||
_ackEmptyPassword = false;
|
||||
if (_ackIdentities.TryGetValue(apiKeyId, out var current))
|
||||
{
|
||||
var slash = current.IndexOf('\\');
|
||||
@@ -339,6 +349,13 @@
|
||||
_ackUser = "";
|
||||
_ackDomain = "";
|
||||
_ackPassword = "";
|
||||
_ackEmptyPassword = false;
|
||||
}
|
||||
|
||||
// A typed password and "Empty password" are mutually exclusive: ticking the box discards what was typed.
|
||||
private void OnAckEmptyPasswordChanged()
|
||||
{
|
||||
if (_ackEmptyPassword) _ackPassword = "";
|
||||
}
|
||||
|
||||
private async Task SaveAckIdentityAsync()
|
||||
@@ -348,7 +365,10 @@
|
||||
_error = null;
|
||||
try
|
||||
{
|
||||
await AckIdentities.SetAsync(id, _ackUser, _ackDomain, _ackPassword, await ActorAsync(), default);
|
||||
if (_ackEmptyPassword)
|
||||
await AckIdentities.SetWithEmptyPasswordAsync(id, _ackUser, _ackDomain, await ActorAsync(), default);
|
||||
else
|
||||
await AckIdentities.SetAsync(id, _ackUser, _ackDomain, _ackPassword, await ActorAsync(), default);
|
||||
CloseAckEditor();
|
||||
await ReloadAsync();
|
||||
}
|
||||
|
||||
+71
-3
@@ -53,6 +53,18 @@
|
||||
<div id="@FieldId("field-07-error")" class="field-error">@if (_fieldEditContext is not null) { <ValidationMessage For="@(() => _form.Galaxy.GatewayStreamTimeoutSeconds)" /> }</div>
|
||||
<div id="@FieldId("field-07-hint")" class="form-text">Default 0 (lifetime of driver).</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label for="@FieldId("field-07a")" class="form-label">Keep-alive ping delay (s)</label>
|
||||
<InputNumber DisplayName="Keep-alive ping delay (s)" aria-describedby="@FieldIds("field-07a-error", "field-07a-hint")" id="@FieldId("field-07a")" @bind-Value="_form.Galaxy.GatewayKeepAlivePingDelaySeconds" @bind-Value:after="EmitAsync" min="0" class="form-control form-control-sm" />
|
||||
<div id="@FieldId("field-07a-error")" class="field-error">@if (_fieldEditContext is not null) { <ValidationMessage For="@(() => _form.Galaxy.GatewayKeepAlivePingDelaySeconds)" /> }</div>
|
||||
<div id="@FieldId("field-07a-hint")" class="form-text">HTTP/2 PING interval on every gateway channel, so a silently dead connection faults the event stream (#991). Default 15; 0 = no pings.</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label for="@FieldId("field-07b")" class="form-label">Keep-alive ping timeout (s)</label>
|
||||
<InputNumber DisplayName="Keep-alive ping timeout (s)" aria-describedby="@FieldIds("field-07b-error", "field-07b-hint")" id="@FieldId("field-07b")" @bind-Value="_form.Galaxy.GatewayKeepAlivePingTimeoutSeconds" @bind-Value:after="EmitAsync" min="0" class="form-control form-control-sm" />
|
||||
<div id="@FieldId("field-07b-error")" class="field-error">@if (_fieldEditContext is not null) { <ValidationMessage For="@(() => _form.Galaxy.GatewayKeepAlivePingTimeoutSeconds)" /> }</div>
|
||||
<div id="@FieldId("field-07b-hint")" class="form-text">How long an unanswered PING may wait before the connection is failed. Default 10.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -86,6 +98,20 @@
|
||||
<div id="@FieldId("field-11-error")" class="field-error">@if (_fieldEditContext is not null) { <ValidationMessage For="@(() => _form.Galaxy.MxEventPumpChannelCapacity)" /> }</div>
|
||||
<div id="@FieldId("field-11-hint")" class="form-text">Default 50000. Raise if events.dropped appears.</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="@FieldId("field-11a")" class="form-label">Secured writes</label>
|
||||
<InputSelect aria-describedby="@FieldIds("field-11a-hint")" id="@FieldId("field-11a")" @bind-Value="_form.Galaxy.MxSecuredWrites" @bind-Value:after="EmitAsync" class="form-select form-select-sm">
|
||||
<option value="@GalaxySecuredWriteMode.Refuse">Refuse (default)</option>
|
||||
<option value="@GalaxySecuredWriteMode.ApiKeyIdentity">Write as the calling API key's Galaxy identity</option>
|
||||
</InputSelect>
|
||||
<div id="@FieldId("field-11a-hint")" class="form-text">
|
||||
How a write to a <code>SecuredWrite</code> attribute is handled (#1017). <em>Refuse</em> answers
|
||||
<code>BadUserAccessDenied</code>. <em>API key identity</em> authenticates as the Galaxy account mapped to the
|
||||
session's key on <a href="/apikeys">API keys</a> and issues <code>WriteSecured</code>; anonymous sessions and keys
|
||||
without an identity are refused (no fallback account). The gateway key needs <code>invoke:secure</code>.
|
||||
<code>VerifiedWrite</code> attributes are always refused.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -213,6 +239,26 @@
|
||||
|
||||
private FormModel _form = new();
|
||||
private string? _lastParsed;
|
||||
// The stored config as loaded (then as last emitted), so keys the form does not model survive a save (#1045).
|
||||
private string? _originalJson;
|
||||
|
||||
/// <summary>
|
||||
/// The DriverConfig paths this form edits (#1045). Everything else in the stored JSON — a newer option, a
|
||||
/// hand-edited key, <c>rawTags</c> — is carried through a save untouched by <see cref="DriverConfigJsonOverlay"/>.
|
||||
/// A new form field MUST add its path here, or its edits are discarded on save.
|
||||
/// </summary>
|
||||
internal static readonly string[] OwnedPaths =
|
||||
[
|
||||
"gateway.endpoint", "gateway.apiKeySecretRef", "gateway.useTls", "gateway.caCertificatePath",
|
||||
"gateway.connectTimeoutSeconds", "gateway.defaultCallTimeoutSeconds", "gateway.streamTimeoutSeconds",
|
||||
"gateway.keepAlivePingDelaySeconds", "gateway.keepAlivePingTimeoutSeconds",
|
||||
"mxAccess.clientName", "mxAccess.publishingIntervalMs", "mxAccess.writeUserId", "mxAccess.eventPumpChannelCapacity",
|
||||
"mxAccess.securedWrites",
|
||||
"repository.discoverPageSize", "repository.watchDeployEvents",
|
||||
"reconnect.initialBackoffMs", "reconnect.maxBackoffMs", "reconnect.replayOnSessionLost",
|
||||
"probeTimeoutSeconds",
|
||||
"alarmAck.fallbackUser", "alarmAck.fallbackDomain", "alarmAck.fallbackPasswordSecretRef", "alarmAck.confirmTimeoutMs",
|
||||
];
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
@@ -220,17 +266,26 @@
|
||||
{
|
||||
var opts = TryDeserialize(DriverConfigJson) ?? CreateDefaultOptions();
|
||||
_form = new FormModel { Galaxy = GalaxyFormModel.FromRecord(opts) };
|
||||
_originalJson = DriverConfigJson;
|
||||
_lastParsed = DriverConfigJson;
|
||||
}
|
||||
}
|
||||
|
||||
public string GetConfigJson()
|
||||
=> JsonSerializer.Serialize(_form.Galaxy.ToRecord(), _jsonOpts);
|
||||
=> Serialize(_form.Galaxy.ToRecord(), _originalJson);
|
||||
|
||||
/// <summary>Serializes <paramref name="options"/> and overlays the form-owned paths onto <paramref name="originalJson"/>.</summary>
|
||||
/// <param name="options">The form's options.</param>
|
||||
/// <param name="originalJson">The stored config, so unmodelled keys survive (#1045); null/blank = the typed JSON alone.</param>
|
||||
/// <returns>The DriverConfig JSON to save.</returns>
|
||||
internal static string Serialize(GalaxyDriverOptions options, string? originalJson)
|
||||
=> DriverConfigJsonOverlay.Apply(originalJson, JsonSerializer.Serialize(options, _jsonOpts), OwnedPaths);
|
||||
|
||||
private async Task EmitAsync()
|
||||
{
|
||||
var json = GetConfigJson();
|
||||
_lastParsed = json;
|
||||
_originalJson = json;
|
||||
await DriverConfigJsonChanged.InvokeAsync(json);
|
||||
}
|
||||
|
||||
@@ -268,12 +323,17 @@
|
||||
public int GatewayConnectTimeoutSeconds { get; set; } = 10;
|
||||
public int GatewayDefaultCallTimeoutSeconds { get; set; } = 30;
|
||||
public int GatewayStreamTimeoutSeconds { get; set; } = 0;
|
||||
[System.ComponentModel.DataAnnotations.Range(0, int.MaxValue, ErrorMessage = "Must be 0 (no pings) or more.")]
|
||||
public int GatewayKeepAlivePingDelaySeconds { get; set; } = 15;
|
||||
[System.ComponentModel.DataAnnotations.Range(0, int.MaxValue, ErrorMessage = "Must be 0 or more.")]
|
||||
public int GatewayKeepAlivePingTimeoutSeconds { get; set; } = 10;
|
||||
|
||||
// GalaxyMxAccessOptions
|
||||
public string MxClientName { get; set; } = "OtOpcUa";
|
||||
public int MxPublishingIntervalMs { get; set; } = 1000;
|
||||
public int MxWriteUserId { get; set; } = 0;
|
||||
public int MxEventPumpChannelCapacity { get; set; } = 50_000;
|
||||
public GalaxySecuredWriteMode MxSecuredWrites { get; set; } = GalaxySecuredWriteMode.Refuse;
|
||||
|
||||
// GalaxyRepositoryOptions
|
||||
public int RepositoryDiscoverPageSize { get; set; } = 5000;
|
||||
@@ -309,10 +369,13 @@
|
||||
GatewayConnectTimeoutSeconds = gw.ConnectTimeoutSeconds,
|
||||
GatewayDefaultCallTimeoutSeconds = gw.DefaultCallTimeoutSeconds,
|
||||
GatewayStreamTimeoutSeconds = gw.StreamTimeoutSeconds,
|
||||
GatewayKeepAlivePingDelaySeconds = gw.KeepAlivePingDelaySeconds,
|
||||
GatewayKeepAlivePingTimeoutSeconds = gw.KeepAlivePingTimeoutSeconds,
|
||||
MxClientName = mx.ClientName,
|
||||
MxPublishingIntervalMs = mx.PublishingIntervalMs,
|
||||
MxWriteUserId = mx.WriteUserId,
|
||||
MxEventPumpChannelCapacity = mx.EventPumpChannelCapacity,
|
||||
MxSecuredWrites = mx.SecuredWrites,
|
||||
RepositoryDiscoverPageSize = repo.DiscoverPageSize,
|
||||
RepositoryWatchDeployEvents = repo.WatchDeployEvents,
|
||||
ReconnectInitialBackoffMs = rc.InitialBackoffMs,
|
||||
@@ -334,12 +397,17 @@
|
||||
CaCertificatePath: string.IsNullOrWhiteSpace(GatewayCaCertificatePath) ? null : GatewayCaCertificatePath,
|
||||
ConnectTimeoutSeconds: GatewayConnectTimeoutSeconds,
|
||||
DefaultCallTimeoutSeconds: GatewayDefaultCallTimeoutSeconds,
|
||||
StreamTimeoutSeconds: GatewayStreamTimeoutSeconds),
|
||||
StreamTimeoutSeconds: GatewayStreamTimeoutSeconds,
|
||||
KeepAlivePingDelaySeconds: GatewayKeepAlivePingDelaySeconds,
|
||||
KeepAlivePingTimeoutSeconds: GatewayKeepAlivePingTimeoutSeconds),
|
||||
MxAccess: new GalaxyMxAccessOptions(
|
||||
ClientName: MxClientName,
|
||||
PublishingIntervalMs: MxPublishingIntervalMs,
|
||||
WriteUserId: MxWriteUserId,
|
||||
EventPumpChannelCapacity: MxEventPumpChannelCapacity),
|
||||
EventPumpChannelCapacity: MxEventPumpChannelCapacity)
|
||||
{
|
||||
SecuredWrites = MxSecuredWrites,
|
||||
},
|
||||
Repository: new GalaxyRepositoryOptions(
|
||||
DiscoverPageSize: RepositoryDiscoverPageSize,
|
||||
WatchDeployEvents: RepositoryWatchDeployEvents),
|
||||
|
||||
@@ -3557,7 +3557,9 @@ public sealed partial class OtOpcUaNodeManager : CustomNodeManager2, INodeManage
|
||||
var clientUserId = identity is { Principal.Length: > 0 } ? identity.Principal : identity?.DisplayName;
|
||||
|
||||
return DispatchDeviceWrite(gateway, nodeKey, nodeBareId, nodeRealm, optimisticValue, priorValue, priorStatus, clientUserId,
|
||||
(node as EquipmentVariableState)?.ActiveWriteStamp);
|
||||
(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));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -3578,12 +3580,14 @@ public sealed partial class OtOpcUaNodeManager : CustomNodeManager2, INodeManage
|
||||
internal ServiceResult DispatchDeviceWrite(
|
||||
IOpcUaNodeWriteGateway gateway, string nodeKey, string nodeBareId, AddressSpaceRealm nodeRealm,
|
||||
object? optimisticValue, object? priorValue, StatusCode priorStatus, string? clientUserId,
|
||||
EquipmentVariableState.WriteStamp? writeStamp = null)
|
||||
EquipmentVariableState.WriteStamp? writeStamp = null, WriteCaller? caller = null)
|
||||
{
|
||||
Task<NodeWriteOutcome> dispatch;
|
||||
try
|
||||
{
|
||||
dispatch = gateway.WriteAsync(nodeKey, optimisticValue, nodeRealm, CancellationToken.None);
|
||||
dispatch = caller is null
|
||||
? gateway.WriteAsync(nodeKey, optimisticValue, nodeRealm, CancellationToken.None)
|
||||
: gateway.WriteAsync(nodeKey, optimisticValue, nodeRealm, caller, CancellationToken.None);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Akka.Actor;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ZB.MOM.WW.OtOpcUa.Commons.OpcUa;
|
||||
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Runtime.Drivers;
|
||||
|
||||
@@ -44,7 +45,12 @@ public sealed class ActorNodeWriteGateway : IOpcUaNodeWriteGateway
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<NodeWriteOutcome> WriteAsync(string nodeId, object? value, AddressSpaceRealm realm, CancellationToken ct)
|
||||
public Task<NodeWriteOutcome> WriteAsync(string nodeId, object? value, AddressSpaceRealm realm, CancellationToken ct)
|
||||
=> WriteAsync(nodeId, value, realm, caller: null, ct);
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<NodeWriteOutcome> WriteAsync(
|
||||
string nodeId, object? value, AddressSpaceRealm realm, WriteCaller? caller, CancellationToken ct)
|
||||
{
|
||||
var driverHost = _resolveDriverHost();
|
||||
if (driverHost is null)
|
||||
@@ -56,7 +62,7 @@ public sealed class ActorNodeWriteGateway : IOpcUaNodeWriteGateway
|
||||
try
|
||||
{
|
||||
var result = await driverHost.Ask<DriverHostActor.NodeWriteResult>(
|
||||
new DriverHostActor.RouteNodeWrite(nodeId, value, realm), _askTimeout, ct).ConfigureAwait(false);
|
||||
new DriverHostActor.RouteNodeWrite(nodeId, value, realm, caller), _askTimeout, ct).ConfigureAwait(false);
|
||||
if (!result.Success)
|
||||
_logger.LogWarning("Operator write to {NodeId} rejected: {Reason}", nodeId, result.Reason);
|
||||
return new NodeWriteOutcome(result.Success, result.Reason);
|
||||
|
||||
@@ -695,7 +695,7 @@ public sealed partial class DriverHostActor : ReceiveActor, IWithTimers, IWithUn
|
||||
/// </summary>
|
||||
/// <param name="NodeId">The folder-scoped equipment-variable NodeId the operator wrote to.</param>
|
||||
/// <param name="Value">The value to write (the driver coerces it to the attribute's data type).</param>
|
||||
public sealed record RouteNodeWrite(string NodeId, object? Value, AddressSpaceRealm Realm);
|
||||
public sealed record RouteNodeWrite(string NodeId, object? Value, AddressSpaceRealm Realm, WriteCaller? Caller = null);
|
||||
|
||||
/// <summary>Reply to <see cref="RouteNodeWrite"/>: the outcome of forwarding the write to the driver
|
||||
/// (or a gate/lookup failure that never reached the driver).</summary>
|
||||
@@ -2613,7 +2613,7 @@ public sealed partial class DriverHostActor : ReceiveActor, IWithTimers, IWithUn
|
||||
var replyTo = Sender;
|
||||
var askDeadline = new CancellationTokenSource(_writeBounds.HostAsk, _writeClock);
|
||||
entry.Actor.Ask<DriverInstanceActor.WriteAttributeResult>(
|
||||
new DriverInstanceActor.WriteAttribute(target.RawPath, msg.Value!, _writeClock.GetTimestamp()),
|
||||
new DriverInstanceActor.WriteAttribute(target.RawPath, msg.Value!, _writeClock.GetTimestamp(), msg.Caller),
|
||||
System.Threading.Timeout.InfiniteTimeSpan,
|
||||
askDeadline.Token)
|
||||
.ContinueWith(
|
||||
|
||||
@@ -136,7 +136,7 @@ public sealed class DriverInstanceActor : ReceiveActor, IWithTimers
|
||||
/// stamps it so the time the write spends in this actor's MAILBOX counts against the queue budget too: a write
|
||||
/// delayed there (behind a hanging alarm subscribe, say) and then started could otherwise still be running
|
||||
/// when the host's Ask fires (lmxopcua#777).</param>
|
||||
public sealed record WriteAttribute(string TagId, object Value, long? IssuedAt = null);
|
||||
public sealed record WriteAttribute(string TagId, object Value, long? IssuedAt = null, WriteCaller? Caller = null);
|
||||
public sealed record WriteAttributeResult(bool Success, string? Reason);
|
||||
internal sealed record WriteAttributeWithOutcome(WriteAdmissionTicket Ticket, WriteClaim Claim);
|
||||
/// <summary>
|
||||
@@ -1669,7 +1669,11 @@ public sealed class DriverInstanceActor : ReceiveActor, IWithTimers
|
||||
var attempt = invoker.ExecuteWriteAsync(
|
||||
hostKey,
|
||||
isIdempotent: false,
|
||||
async ct => await writable.WriteAsync(request, ct),
|
||||
// #1017: a write that carries its caller reaches a driver that can act on it (the Galaxy driver's
|
||||
// SecuredWrite attributes) through ICallerAwareWritable; every other driver/write is unchanged.
|
||||
async ct => msg.Caller is { } caller && writable is ICallerAwareWritable callerAware
|
||||
? await callerAware.WriteAsync(request, caller, ct)
|
||||
: await writable.WriteAsync(request, ct),
|
||||
cts.Token).AsTask();
|
||||
IReadOnlyList<WriteResult> results;
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user