feat(secrets): resolve MxGateway ApiKey secret: refs at connect time (ScadaBridge G-3 T9)
This commit is contained in:
@@ -2,6 +2,7 @@ using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Protocol;
|
||||
using ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Adapters;
|
||||
using ZB.MOM.WW.Secrets.Abstractions;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer;
|
||||
|
||||
@@ -13,6 +14,7 @@ public class DataConnectionFactory : IDataConnectionFactory
|
||||
{
|
||||
private readonly Dictionary<string, Func<IDictionary<string, string>, IDataConnection>> _factories = new(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
private readonly ISecretResolver? _secretResolver;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new <see cref="DataConnectionFactory"/> with default OPC UA global options.
|
||||
@@ -26,9 +28,19 @@ public class DataConnectionFactory : IDataConnectionFactory
|
||||
/// </summary>
|
||||
/// <param name="loggerFactory">Logger factory used when creating protocol adapters.</param>
|
||||
/// <param name="opcUaGlobalOptions">Global OPC UA options applied to all OPC UA connections created by this factory.</param>
|
||||
public DataConnectionFactory(ILoggerFactory loggerFactory, IOptions<OpcUaGlobalOptions> opcUaGlobalOptions)
|
||||
/// <param name="secretResolver">
|
||||
/// Optional secret resolver threaded into the MxGateway adapter so a per-endpoint
|
||||
/// <c>secret:<name></c> ApiKey reference is resolved at connect time. DI supplies it on
|
||||
/// the Site container (where <see cref="ISecretResolver"/> is registered); direct
|
||||
/// construction without it keeps literal-key behaviour.
|
||||
/// </param>
|
||||
public DataConnectionFactory(
|
||||
ILoggerFactory loggerFactory,
|
||||
IOptions<OpcUaGlobalOptions> opcUaGlobalOptions,
|
||||
ISecretResolver? secretResolver = null)
|
||||
{
|
||||
_loggerFactory = loggerFactory;
|
||||
_secretResolver = secretResolver;
|
||||
var globalOptions = opcUaGlobalOptions.Value;
|
||||
|
||||
// Register built-in protocols.
|
||||
@@ -44,7 +56,8 @@ public class DataConnectionFactory : IDataConnectionFactory
|
||||
// flat details dict (see MxGatewayEndpointConfigSerializer).
|
||||
RegisterAdapter("MxGateway", details => new MxGatewayDataConnection(
|
||||
new RealMxGatewayClientFactory(_loggerFactory),
|
||||
_loggerFactory.CreateLogger<MxGatewayDataConnection>()));
|
||||
_loggerFactory.CreateLogger<MxGatewayDataConnection>(),
|
||||
_secretResolver));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user