66 lines
3.6 KiB
C#
66 lines
3.6 KiB
C#
using Microsoft.Extensions.Options;
|
|
|
|
namespace ZB.MOM.WW.MxGateway.Server.Configuration;
|
|
|
|
/// <summary>Provides the effective gateway configuration with sensitive values redacted.</summary>
|
|
public sealed class GatewayConfigurationProvider(IOptions<GatewayOptions> options) : IGatewayConfigurationProvider
|
|
{
|
|
/// <summary>Marker string for redacted sensitive configuration values.</summary>
|
|
public const string RedactedValue = "[redacted]";
|
|
|
|
/// <inheritdoc />
|
|
public EffectiveGatewayConfiguration GetEffectiveConfiguration()
|
|
{
|
|
GatewayOptions value = options.Value;
|
|
|
|
return new EffectiveGatewayConfiguration(
|
|
Authentication: new EffectiveAuthenticationConfiguration(
|
|
Mode: value.Authentication.Mode.ToString(),
|
|
SqlitePath: value.Authentication.SqlitePath,
|
|
PepperSecretName: RedactedValue,
|
|
RunMigrationsOnStartup: value.Authentication.RunMigrationsOnStartup),
|
|
Ldap: new EffectiveLdapConfiguration(
|
|
Enabled: value.Ldap.Enabled,
|
|
Server: value.Ldap.Server,
|
|
Port: value.Ldap.Port,
|
|
Transport: value.Ldap.Transport.ToString(),
|
|
AllowInsecure: value.Ldap.AllowInsecure,
|
|
SearchBase: value.Ldap.SearchBase,
|
|
ServiceAccountDn: value.Ldap.ServiceAccountDn,
|
|
ServiceAccountPassword: RedactedValue,
|
|
UserNameAttribute: value.Ldap.UserNameAttribute,
|
|
DisplayNameAttribute: value.Ldap.DisplayNameAttribute,
|
|
GroupAttribute: value.Ldap.GroupAttribute),
|
|
Worker: new EffectiveWorkerConfiguration(
|
|
ExecutablePath: value.Worker.ExecutablePath,
|
|
WorkingDirectory: value.Worker.WorkingDirectory,
|
|
RequiredArchitecture: value.Worker.RequiredArchitecture.ToString(),
|
|
StartupTimeoutSeconds: value.Worker.StartupTimeoutSeconds,
|
|
ShutdownTimeoutSeconds: value.Worker.ShutdownTimeoutSeconds,
|
|
HeartbeatIntervalSeconds: value.Worker.HeartbeatIntervalSeconds,
|
|
HeartbeatGraceSeconds: value.Worker.HeartbeatGraceSeconds,
|
|
MaxMessageBytes: value.Worker.MaxMessageBytes),
|
|
Sessions: new EffectiveSessionConfiguration(
|
|
DefaultCommandTimeoutSeconds: value.Sessions.DefaultCommandTimeoutSeconds,
|
|
MaxSessions: value.Sessions.MaxSessions,
|
|
MaxPendingCommandsPerSession: value.Sessions.MaxPendingCommandsPerSession,
|
|
DefaultLeaseSeconds: value.Sessions.DefaultLeaseSeconds,
|
|
LeaseSweepIntervalSeconds: value.Sessions.LeaseSweepIntervalSeconds,
|
|
AllowMultipleEventSubscribers: value.Sessions.AllowMultipleEventSubscribers),
|
|
Events: new EffectiveEventConfiguration(
|
|
QueueCapacity: value.Events.QueueCapacity,
|
|
BackpressurePolicy: value.Events.BackpressurePolicy.ToString()),
|
|
Dashboard: new EffectiveDashboardConfiguration(
|
|
Enabled: value.Dashboard.Enabled,
|
|
AllowAnonymousLocalhost: value.Dashboard.AllowAnonymousLocalhost,
|
|
SnapshotIntervalMilliseconds: value.Dashboard.SnapshotIntervalMilliseconds,
|
|
RecentFaultLimit: value.Dashboard.RecentFaultLimit,
|
|
RecentSessionLimit: value.Dashboard.RecentSessionLimit,
|
|
ShowTagValues: value.Dashboard.ShowTagValues,
|
|
GroupToRole: value.Dashboard.GroupToRole),
|
|
Protocol: new EffectiveProtocolConfiguration(
|
|
value.Protocol.WorkerProtocolVersion,
|
|
value.Protocol.MaxGrpcMessageBytes));
|
|
}
|
|
}
|