aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/auth.rs32
-rw-r--r--src/config.rs6
-rw-r--r--src/main.rs4
-rw-r--r--src/server.rs4
4 files changed, 46 insertions, 0 deletions
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<ImapConfig>,
pub imap_unsecure: Option<ImapUnsecureConfig>,
pub lmtp: Option<LmtpConfig>,
+ pub auth: Option<AuthConfig>,
pub users: UserManagement,
}
@@ -33,6 +34,11 @@ pub enum UserManagement {
}
#[derive(Serialize, Deserialize, Debug, Clone)]
+pub struct AuthConfig {
+ pub bind_addr: SocketAddr,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct LmtpConfig {
pub bind_addr: SocketAddr,
pub hostname: String,
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<Arc<LmtpServer>>,
imap_unsecure_server: Option<imap::Server>,
imap_server: Option<imap::Server>,
+ auth_server: Option<auth::AuthServer>,
pid_file: Option<PathBuf>,
}
@@ -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,
})
}