//! Authentication models shared across protocol connectors. #![forbid(unsafe_code)] use std::collections::HashMap; /// Authentication scheme recognized by the protocol layer. #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum AuthScheme { /// HTTP Basic authentication. Basic, /// HTTP Digest authentication. Digest, /// Bearer-token authentication. Bearer, /// SPNEGO or Negotiate authentication. Negotiate, /// NTLM authentication. Ntlm, /// OAuth2-derived bearer flows. OAuth2, /// Caller accepts any supported scheme. Any, } /// Authentication material supplied to a protocol connector. #[derive(Clone, Debug, Eq, PartialEq)] pub struct AuthCredentialModel { /// Scheme the credential applies to. pub scheme: AuthScheme, /// Optional username component. pub username: Option, /// Optional password or shared secret. pub password: Option, /// Optional opaque bearer token. pub token: Option, /// Optional authentication realm. pub realm: Option, } /// Authentication challenge emitted by a server. #[derive(Clone, Debug, Eq, PartialEq)] pub struct AuthChallengeModel { /// Challenged scheme. pub scheme: AuthScheme, /// Optional realm attached to the challenge. pub realm: Option, /// Additional challenge parameters keyed by attribute name. pub parameters: HashMap, } /// Cached credential entry associated with an origin. #[derive(Clone, Debug, Eq, PartialEq)] pub struct AuthCacheEntry { /// Origin or protection-space key. pub origin: String, /// Credential cached for the origin. pub credential: AuthCredentialModel, }