Path: redb-route/redb.Route.SignalR/SignalRConnectionFactory.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.SignalR/SignalRConnectionFactory.cs
----
using redb.Route.Abstractions;
using redb.Route.Core;
namespace redb.Route.SignalR;
///
/// Named connection factory for SignalR. Register it in the route registry and reference it by
/// name from the endpoint URI (connectionFactory=my-hub) so the access token and TLS
/// certificate password never have to appear in the URI, and therefore can never reach logs,
/// telemetry, or the dashboard.
///
/// The hub address stays in the endpoint path — a factory carries credentials and TLS material
/// only and can never silently redirect a route.
///
///
public sealed class SignalRConnectionFactory
{
/// Bearer access token for hub authentication.
[Sensitive]
public string? AccessToken { get; set; }
/// Transport to use (WebSockets, ServerSentEvents, LongPolling).
public SignalRTransport Transport { get; set; } = SignalRTransport.WebSockets;
/// Serve/connect over TLS.
public bool Ssl { get; set; }
/// Path to the PFX certificate.
public string? SslCertPath { get; set; }
/// Password for the PFX certificate.
[Sensitive]
public string? SslCertPassword { get; set; }
///
/// Copies this factory's credential and TLS settings onto the endpoint options, but only for
/// parameters the endpoint URI did not set explicitly — an inline URI value always wins.
///
internal void ApplyTo(SignalREndpointOptions options, EndpointUri uri)
{
var supplied = uri.RawParameters;
if (!supplied.ContainsKey(nameof(options.AccessToken))) options.AccessToken = AccessToken;
if (!supplied.ContainsKey(nameof(options.Transport))) options.Transport = Transport;
if (!supplied.ContainsKey(nameof(options.Ssl))) options.Ssl = Ssl;
if (!supplied.ContainsKey(nameof(options.SslCertPath))) options.SslCertPath = SslCertPath;
if (!supplied.ContainsKey(nameof(options.SslCertPassword)))
options.SslCertPassword = SslCertPassword;
}
}