using System.Security.Cryptography.X509Certificates; using NATS.Server.Auth.Jwt; using NATS.Server.Protocol; namespace NATS.Server.Auth; public interface IAuthenticator { /// /// Attempts to authenticate a client connection. /// /// Authentication context containing credentials and transport metadata. AuthResult? Authenticate(ClientAuthContext context); } public sealed class ClientAuthContext { /// /// Gets CONNECT options and credential fields supplied by the client. /// public required ClientOptions Opts { get; init; } /// /// Gets server-issued nonce bytes used for signature-based auth flows. /// public required byte[] Nonce { get; init; } /// /// Gets the client TLS certificate presented during handshake, when available. /// public X509Certificate2? ClientCertificate { get; init; } /// /// The type of connection (e.g., "STANDARD", "WEBSOCKET", "MQTT", "LEAFNODE"). /// Used by JWT authenticator to enforce allowed_connection_types claims. /// Defaults to "STANDARD" for regular NATS client connections. /// public string ConnectionType { get; init; } = JwtConnectionTypes.Standard; }