2022-03-12 01:27:58 +01:00
|
|
|
use std::sync::Arc;
|
|
|
|
use rsasl::error::SASLError;
|
|
|
|
use rsasl::mechname::Mechname;
|
|
|
|
use rsasl::SASL;
|
|
|
|
use rsasl::session::Session;
|
2022-03-08 18:52:49 +01:00
|
|
|
|
2022-03-10 20:52:34 +01:00
|
|
|
pub mod db;
|
|
|
|
|
2022-03-12 01:27:58 +01:00
|
|
|
struct Inner {
|
|
|
|
rsasl: SASL,
|
|
|
|
}
|
|
|
|
impl Inner {
|
|
|
|
pub fn new(rsasl: SASL) -> Self {
|
|
|
|
Self { rsasl }
|
|
|
|
}
|
|
|
|
}
|
2022-03-10 20:52:34 +01:00
|
|
|
|
2022-03-12 01:27:58 +01:00
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct AuthenticationHandler {
|
|
|
|
inner: Arc<Inner>,
|
2022-03-10 20:52:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
impl AuthenticationHandler {
|
2022-03-12 01:27:58 +01:00
|
|
|
pub fn new(rsasl: SASL) -> Self {
|
|
|
|
Self { inner: Arc::new(Inner::new(rsasl)) }
|
|
|
|
}
|
2022-03-10 20:52:34 +01:00
|
|
|
|
2022-03-12 01:27:58 +01:00
|
|
|
pub fn start(&self, mechanism: &Mechname) -> Result<Session, SASLError> {
|
|
|
|
self.inner.rsasl.server_start(mechanism)
|
|
|
|
}
|
2022-03-10 20:52:34 +01:00
|
|
|
}
|