WIP Dovecot Authentication Protocol Server
This commit is contained in:
parent
f67f04129a
commit
9a265a09e2
4 changed files with 46 additions and 0 deletions
32
src/auth.rs
Normal file
32
src/auth.rs
Normal file
|
@ -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,
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ pub struct ProviderConfig {
|
||||||
pub imap: Option<ImapConfig>,
|
pub imap: Option<ImapConfig>,
|
||||||
pub imap_unsecure: Option<ImapUnsecureConfig>,
|
pub imap_unsecure: Option<ImapUnsecureConfig>,
|
||||||
pub lmtp: Option<LmtpConfig>,
|
pub lmtp: Option<LmtpConfig>,
|
||||||
|
pub auth: Option<AuthConfig>,
|
||||||
pub users: UserManagement,
|
pub users: UserManagement,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +33,11 @@ pub enum UserManagement {
|
||||||
Ldap(LoginLdapConfig),
|
Ldap(LoginLdapConfig),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
|
pub struct AuthConfig {
|
||||||
|
pub bind_addr: SocketAddr,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct LmtpConfig {
|
pub struct LmtpConfig {
|
||||||
pub bind_addr: SocketAddr,
|
pub bind_addr: SocketAddr,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#![feature(async_fn_in_trait)]
|
#![feature(async_fn_in_trait)]
|
||||||
|
|
||||||
|
mod auth;
|
||||||
mod bayou;
|
mod bayou;
|
||||||
mod config;
|
mod config;
|
||||||
mod cryptoblob;
|
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),
|
bind_addr: SocketAddr::new(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)), 1025),
|
||||||
hostname: "example.tld".to_string(),
|
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,
|
users: UserManagement::Demo,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -9,6 +9,7 @@ use tokio::sync::watch;
|
||||||
|
|
||||||
use crate::config::*;
|
use crate::config::*;
|
||||||
use crate::imap;
|
use crate::imap;
|
||||||
|
use crate::auth;
|
||||||
use crate::lmtp::*;
|
use crate::lmtp::*;
|
||||||
use crate::login::ArcLoginProvider;
|
use crate::login::ArcLoginProvider;
|
||||||
use crate::login::{demo_provider::*, ldap_provider::*, static_provider::*};
|
use crate::login::{demo_provider::*, ldap_provider::*, static_provider::*};
|
||||||
|
@ -17,6 +18,7 @@ pub struct Server {
|
||||||
lmtp_server: Option<Arc<LmtpServer>>,
|
lmtp_server: Option<Arc<LmtpServer>>,
|
||||||
imap_unsecure_server: Option<imap::Server>,
|
imap_unsecure_server: Option<imap::Server>,
|
||||||
imap_server: Option<imap::Server>,
|
imap_server: Option<imap::Server>,
|
||||||
|
auth_server: Option<auth::AuthServer>,
|
||||||
pid_file: Option<PathBuf>,
|
pid_file: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +33,7 @@ impl Server {
|
||||||
lmtp_server,
|
lmtp_server,
|
||||||
imap_unsecure_server,
|
imap_unsecure_server,
|
||||||
imap_server: None,
|
imap_server: None,
|
||||||
|
auth_server: None,
|
||||||
pid_file: config.pid,
|
pid_file: config.pid,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -51,6 +54,7 @@ impl Server {
|
||||||
lmtp_server,
|
lmtp_server,
|
||||||
imap_unsecure_server,
|
imap_unsecure_server,
|
||||||
imap_server,
|
imap_server,
|
||||||
|
auth_server: None,
|
||||||
pid_file: config.pid,
|
pid_file: config.pid,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue