Path: redb-route/redb.Route.Sftp/SftpConnectionFactory.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Sftp/SftpConnectionFactory.cs ---- using redb.Route.Abstractions; using redb.Route.GenericFile; using redb.Route.Core; namespace redb.Route.Sftp; /// /// Named connection factory for SFTP. Register it in the route registry and reference it by name /// from the endpoint URI (connectionFactory=my-sftp) so the password, private-key /// passphrase and proxy password never have to appear in the URI, and therefore can never reach /// logs, telemetry, or the dashboard. /// /// Example: /// /// context.AddToRegistry("partner-sftp", new SftpConnectionFactory /// { /// Host = "sftp.partner.com", Port = 22, Username = "svc-drop", /// PrivateKeyPath = "/etc/redb/keys/partner.pem", /// PrivateKeyPassphrase = Environment.GetEnvironmentVariable("SFTP_PASSPHRASE")! /// }); /// /// r.From("sftp://inbox?connectionFactory=partner-sftp") // no secrets in the route /// /// /// public sealed class SftpConnectionFactory : RemoteFileConnectionFactory { /// Path to the private key file. public string PrivateKeyPath { get; set; } = ""; /// Passphrase protecting the private key. [Sensitive] public string PrivateKeyPassphrase { get; set; } = ""; /// Preferred authentication methods, comma-separated. public string PreferredAuthentications { get; set; } = ""; /// Expected server host-key fingerprint. public string ServerFingerprint { get; set; } = ""; /// Enforce known-hosts checking. public bool StrictHostKeyChecking { get; set; } /// Path to the known_hosts file. public string KnownHostsFile { get; set; } = ""; /// Proxy host, when connecting through a proxy. public string ProxyHost { get; set; } = ""; /// Proxy port. public int ProxyPort { get; set; } = 1080; /// Proxy username. public string ProxyUsername { get; set; } = ""; /// Proxy password. [Sensitive] public string ProxyPassword { get; set; } = ""; /// internal override void ApplyTo(RemoteFileEndpointOptions options, EndpointUri uri) { base.ApplyTo(options, uri); if (options is not SftpEndpointOptions sftp) return; var supplied = uri.RawParameters; if (!supplied.ContainsKey(nameof(sftp.PrivateKeyPath))) sftp.PrivateKeyPath = PrivateKeyPath; if (!supplied.ContainsKey(nameof(sftp.PrivateKeyPassphrase))) sftp.PrivateKeyPassphrase = PrivateKeyPassphrase; if (!supplied.ContainsKey(nameof(sftp.PreferredAuthentications))) sftp.PreferredAuthentications = PreferredAuthentications; if (!supplied.ContainsKey(nameof(sftp.ServerFingerprint))) sftp.ServerFingerprint = ServerFingerprint; if (!supplied.ContainsKey(nameof(sftp.StrictHostKeyChecking))) sftp.StrictHostKeyChecking = StrictHostKeyChecking; if (!supplied.ContainsKey(nameof(sftp.KnownHostsFile))) sftp.KnownHostsFile = KnownHostsFile; if (!supplied.ContainsKey(nameof(sftp.ProxyHost))) sftp.ProxyHost = ProxyHost; if (!supplied.ContainsKey(nameof(sftp.ProxyPort))) sftp.ProxyPort = ProxyPort; if (!supplied.ContainsKey(nameof(sftp.ProxyUsername))) sftp.ProxyUsername = ProxyUsername; if (!supplied.ContainsKey(nameof(sftp.ProxyPassword))) sftp.ProxyPassword = ProxyPassword; } }