13521354cc
- MxAccess.SecuredWrites = Refuse (default, unchanged #991 local BadUserAccessDenied) | ApiKeyIdentity. Opted in, a SecuredWrite runs as the calling key's own /api-keys Galaxy identity (ResolveKeyIdentityAsync: no fallback account; anonymous / no identity / broken identity refused before the wire): own plain-advised handle (apart from the raw path's supervisory handle) -> AuthenticateUser every write -> WriteSecured(userId, 0), the sequence mxaccessgw live-captured committing. Auth failure / user id 0 -> BadUserAccessDenied; password only in the AuthenticateUser command, scrubbed from every log. Identity resolved once per batch. - VerifiedWrite is refused in every mode: an OPC UA Write carries no verifier (MXAccess refuses no verifier 1008 / self-verifier 8018), and a stored verifier would defeat the two-person rule. - Caller plumbing: WriteCaller + optional ICallerAwareWritable (Core.Abstractions); node manager passes principal + key id -> IOpcUaNodeWriteGateway caller overload (default drops it) -> RouteNodeWrite.Caller -> WriteAttribute.Caller -> ICallerAwareWritable. The gRPC data-connection write path carries no caller yet (secured writes refused there). - AdminUI Galaxy form 'Secured writes' select (owned path); enum serialises as its name; factory refuses an unknown value. Docs: Galaxy.md design + live-gate checklist. Not live-gated.
46 lines
2.0 KiB
C#
46 lines
2.0 KiB
C#
using ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Runtime;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Tests.Runtime;
|
|
|
|
/// <summary>
|
|
/// <see cref="IGalaxyAckCredentialResolver"/> test double that resolves every acknowledge to one fixed
|
|
/// credential (or refuses all), recording the key ids it was asked about.
|
|
/// </summary>
|
|
internal sealed class FixedAckCredentialResolver : IGalaxyAckCredentialResolver
|
|
{
|
|
private readonly GalaxyAckCredential? _credential;
|
|
|
|
private FixedAckCredentialResolver(GalaxyAckCredential? credential) => _credential = credential;
|
|
|
|
/// <summary>Gets the key ids the driver resolved for, in order.</summary>
|
|
public List<string?> RequestedKeyIds { get; } = [];
|
|
|
|
/// <summary>A resolver that always returns a fallback account <c>ACKDOM\ack-op</c> / <c>pw</c>.</summary>
|
|
public static FixedAckCredentialResolver Fallback() =>
|
|
new(new GalaxyAckCredential("ack-op", "ACKDOM", "pw", GalaxyAckCredentialSource.Fallback));
|
|
|
|
/// <summary>A resolver that refuses every acknowledge.</summary>
|
|
public static FixedAckCredentialResolver RefuseAll() => new(null);
|
|
|
|
/// <inheritdoc />
|
|
public Task<GalaxyAckCredentialResolution> ResolveAsync(string? apiKeyId, CancellationToken cancellationToken)
|
|
{
|
|
RequestedKeyIds.Add(apiKeyId);
|
|
return Task.FromResult(_credential is null
|
|
? GalaxyAckCredentialResolution.Refused("test refusal")
|
|
: GalaxyAckCredentialResolution.Resolved(_credential));
|
|
}
|
|
|
|
/// <summary>Gets the key ids a secured write resolved for (#1017), in order.</summary>
|
|
public List<string?> SecuredWriteKeyIds { get; } = [];
|
|
|
|
/// <inheritdoc />
|
|
public Task<GalaxyAckCredentialResolution> ResolveKeyIdentityAsync(string? apiKeyId, CancellationToken cancellationToken)
|
|
{
|
|
SecuredWriteKeyIds.Add(apiKeyId);
|
|
return Task.FromResult(_credential is null || apiKeyId is null
|
|
? GalaxyAckCredentialResolution.Refused("test refusal (no key identity)")
|
|
: GalaxyAckCredentialResolution.Resolved(_credential));
|
|
}
|
|
}
|