namespace NATS.Server.Auth; public interface IExternalAuthClient { /// /// Requests an allow/deny decision from an external authentication provider. /// /// Credential material and identity hints from the client connection. /// Cancellation token bound to auth timeout and connection lifecycle. Task AuthorizeAsync(ExternalAuthRequest request, CancellationToken ct); } public sealed record ExternalAuthRequest( string? Username, string? Password, string? Token, string? Jwt); public record ExternalAuthDecision( bool Allowed, string? Identity = null, string? Account = null, string? Reason = null); public sealed class ExternalAuthOptions { /// /// Gets or sets a value indicating whether external auth callouts are enabled. /// public bool Enabled { get; set; } /// /// Gets or sets the timeout budget for each external auth decision request. /// public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(2); /// /// Gets or sets the client implementation responsible for external auth decisions. /// public IExternalAuthClient? Client { get; set; } } public sealed class ProxyAuthOptions { /// /// Gets or sets a value indicating whether trusted-proxy authentication mode is enabled. /// public bool Enabled { get; set; } /// /// Gets or sets the required username prefix marking identities provided by a trusted proxy. /// public string UsernamePrefix { get; set; } = "proxy:"; /// /// Gets or sets the default account to assign when proxy-authenticated users omit one. /// public string? Account { get; set; } }