auth
ModuleSASL mechanisms for the AUTH command (RFC 4954).
Contents
use utopia_smtp::auth::Login;Rust
pub struct LoginThe mechanism every server implements anyway: username, then password, each in answer to a prompt.
Rust
use utopia_smtp::auth::{Authenticator, Login};
let login = Login::new("jane", "secret");
assert_eq!(login.initial(), None);
assert_eq!(login.respond(b"Username:", 0), b"jane");
assert_eq!(login.respond(b"Password:", 1), b"secret");use utopia_smtp::auth::Plain;Rust
pub struct PlainRFC 4616: both credentials in the initial response, one round trip.
Rust
use utopia_smtp::auth::{Authenticator, Plain};
assert_eq!(Plain::new("jane", "secret").initial(), Some(b"\0jane\0secret".to_vec()));use utopia_smtp::auth::XOAuth2;Rust
pub struct XOAuth2Google's and Microsoft's bearer-token mechanism.
Rust
use utopia_smtp::auth::{Authenticator, XOAuth2};
let oauth = XOAuth2::new("jane@example.test", "token-value");
assert_eq!(oauth.initial(), Some(b"user=jane@example.test\x01auth=Bearer token-value\x01\x01".to_vec()));
assert_eq!(oauth.respond(b"{\"status\":\"401\"}", 0), b"");use utopia_smtp::auth::Authenticator;Rust
pub trait Authenticator: Send + SyncOne RFC 4954 mechanism. The client tries its authenticators in order against what the server advertises, so the order is the security policy.
Implement it for a mechanism this crate does not ship.