From 9a265a09e24f6bebf6a6e327da5dd9dfd4dfa866 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Tue, 23 Jan 2024 21:09:57 +0100 Subject: WIP Dovecot Authentication Protocol Server --- src/auth.rs | 32 ++++++++++++++++++++++++++++++++ src/config.rs | 6 ++++++ src/main.rs | 4 ++++ src/server.rs | 4 ++++ 4 files changed, 46 insertions(+) create mode 100644 src/auth.rs (limited to 'src') diff --git a/src/auth.rs b/src/auth.rs new file mode 100644 index 0000000..27ff1e6 --- /dev/null +++ b/src/auth.rs @@ -0,0 +1,32 @@ +use std::net::SocketAddr; + +/// Seek compatibility with the Dovecot Authentication Protocol +/// +/// ## Trace +/// +/// ```text +/// S: VERSION 1 2 +/// S: MECH PLAIN plaintext +/// S: MECH LOGIN plaintext +/// S: SPID 15 +/// S: CUID 17654 +/// S: COOKIE f56692bee41f471ed01bd83520025305 +/// S: DONE +/// C: VERSION 1 2 +/// C: CPID 1 +/// C: AUTH 2 PLAIN service=smtp +/// S: CONT 2 +/// C: CONT 2 base64string== +/// S: OK 2 user=alice@example.tld +/// ``` +/// +/// ## Dovecot References +/// +/// https://doc.dovecot.org/developer_manual/design/auth_protocol/ +/// https://doc.dovecot.org/configuration_manual/authentication/authentication_mechanisms/#authentication-authentication-mechanisms +/// https://doc.dovecot.org/configuration_manual/howto/simple_virtual_install/#simple-virtual-install-smtp-auth +/// https://doc.dovecot.org/configuration_manual/howto/postfix_and_dovecot_sasl/#howto-postfix-and-dovecot-sasl + +pub struct AuthServer { + bind_addr: SocketAddr, +} diff --git a/src/config.rs b/src/config.rs index 0269773..faaa1ba 100644 --- a/src/config.rs +++ b/src/config.rs @@ -21,6 +21,7 @@ pub struct ProviderConfig { pub imap: Option, pub imap_unsecure: Option, pub lmtp: Option, + pub auth: Option, pub users: UserManagement, } @@ -32,6 +33,11 @@ pub enum UserManagement { Ldap(LoginLdapConfig), } +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct AuthConfig { + pub bind_addr: SocketAddr, +} + #[derive(Serialize, Deserialize, Debug, Clone)] pub struct LmtpConfig { pub bind_addr: SocketAddr, diff --git a/src/main.rs b/src/main.rs index 3e3674c..34d5a11 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ #![feature(async_fn_in_trait)] +mod auth; mod bayou; mod config; mod cryptoblob; @@ -175,6 +176,9 @@ async fn main() -> Result<()> { bind_addr: SocketAddr::new(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)), 1025), hostname: "example.tld".to_string(), }), + auth: Some(AuthConfig { + bind_addr: SocketAddr::new(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)), 12345), + }), users: UserManagement::Demo, }) } else { diff --git a/src/server.rs b/src/server.rs index 0df1caf..6210059 100644 --- a/src/server.rs +++ b/src/server.rs @@ -9,6 +9,7 @@ use tokio::sync::watch; use crate::config::*; use crate::imap; +use crate::auth; use crate::lmtp::*; use crate::login::ArcLoginProvider; use crate::login::{demo_provider::*, ldap_provider::*, static_provider::*}; @@ -17,6 +18,7 @@ pub struct Server { lmtp_server: Option>, imap_unsecure_server: Option, imap_server: Option, + auth_server: Option, pid_file: Option, } @@ -31,6 +33,7 @@ impl Server { lmtp_server, imap_unsecure_server, imap_server: None, + auth_server: None, pid_file: config.pid, }) } @@ -51,6 +54,7 @@ impl Server { lmtp_server, imap_unsecure_server, imap_server, + auth_server: None, pid_file: config.pid, }) } -- cgit v1.2.3