Merge #835 #836 per-instance credential references, confined user-certificate path

This commit is contained in:
Joseph Doherty
2026-11-11 03:53:12 -05:00
35 changed files with 1667 additions and 53 deletions
@@ -59,7 +59,7 @@
}
<div class="mt-3">
<DriverTestConnectButton DriverType="@_driverType" GetConfigJson="@BuildMergedProbeConfig" />
<DriverTestConnectButton DriverType="@_driverType" GetConfigJson="@BuildMergedProbeConfig" DriverInstanceId="@_resolvedDriverInstanceId" />
</div>
<SaveRefusalNotice GateError="@DriverConfigSaveGate.Validate(_driverType, _deviceConfigJson)" SaveError="@_saveError" />
@@ -58,6 +58,12 @@
/// </summary>
[Parameter] public int TimeoutSeconds { get; set; } = TestConnectBudget.DefaultSeconds;
/// <summary>
/// The driver instance the config belongs to (lmxopcua#835: its own <c>secret:&lt;ns&gt;/&lt;id&gt;/…</c> references are
/// allowed, another instance's are refused). Null ⇒ treated as a not-yet-created instance (stricter).
/// </summary>
[Parameter] public string? DriverInstanceId { get; set; }
private const int ClearAfterMs = 30_000;
private bool _busy;
@@ -81,7 +87,7 @@
var json = GetConfigJson() ?? "{}";
var budget = TestConnectBudget.Resolve(json, TimeoutSeconds, DriverType);
_lastBudgetSeconds = budget;
_result = await Probe.TestAsync(DriverType, json, budget);
_result = await Probe.TestAsync(DriverType, json, budget, driverInstanceId: DriverInstanceId);
}
catch (Exception ex)
{
@@ -146,7 +146,8 @@
<div class="col-md-6">
<label class="form-label">User certificate path (PFX/PEM)</label>
<InputText @bind-Value="_form.OpcUa.UserCertificatePath" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono"
placeholder="C:\certs\user.pfx" />
placeholder="plant1/user.pfx" />
<div class="form-text">Relative path inside the node's user-certificate directory (<code>Drivers:OpcUaClient:UserCertificateDirectory</code>, default <code>&lt;LocalAppData&gt;/OtOpcUa/pki/user-certificates</code>). Absolute paths and <code>..</code> are refused (#836).</div>
</div>
<div class="col-md-4">
<label class="form-label">Certificate password (if PFX-locked)</label>
@@ -463,7 +463,12 @@
StateHasChanged();
try
{
var result = await BrowserService.OpenAsync(_driverType, _mergedConfig, default);
// lmxopcua#835: name the owning driver so its own secret:<ns>/<id>/… references are told apart from
// another instance's (an unresolvable owner is treated as a new driver — stricter).
var ownerDriverId = string.IsNullOrEmpty(_effectiveDeviceId)
? null
: await Svc.LoadDeviceDriverInstanceIdAsync(_effectiveDeviceId);
var result = await BrowserService.OpenAsync(_driverType, _mergedConfig, ownerDriverId, default);
// Host disposed, modal closed, or modal re-opened mid-open: close the session nobody will (R04 L4).
if (BrowseOpenGuard.CloseIfOrphaned(result, _disposed || IsStale(generation), BrowserService)) { return; }
if (result.Ok)