Expand description
§Sasl
This module provides support for SASL (Simple Authentication and Security Layer), as specified in RFC4422
It allows one to use these mechanisms to authenticate with a Pop3 compatible server and implement more mechanisms if they are needed.
The mechanisms for PLAIN and XOAUTH2 are already present as they are commonly used.
Implementing a mechanism is simple:
ⓘ
pub struct MyAuthenticator {
username: String,
secret_token: String,
}
impl Authenticator for MyAuthenticator {
fn mechanism(&self) -> &str {
"SUPER_COOL_MECHANISM"
}
fn auth(&self) -> Option<String> {
// Specify your cool format
Some(format!("\x00{}\x00{}", self.username, self.secret_token))
}
async fn handle<'a, S: Read + Write + Unpin + Send>(
&self,
communicator: Communicator<'a, S>,
) -> Result<()> {
let challenge = communicator.next_challenge().await?;
let response = mechanism_lib::handle_challenge(challenge)?;
communicator.send(response).await?;
Ok(())
}
}
Structs§
- Communicator
- OAuth2
Authenticator - A simple mechanism to authenticate via OAuth2
- Plain
Authenticator - A simple mechanism to authenticate via PLAIN