use limes_proto::{AuthOutcome, AuthRequest, AuthSuccess};
use crate::Result;
pub trait AuthBackend: Send + Sync {
fn authenticate(&self, request: &AuthRequest) -> AuthOutcome;
fn open_session(&self, user: &AuthSuccess) -> Result<Vec<(String, String)>>;
fn close_session(&self, auth_session_id: Option<&str>) -> Result<()>;
}
pub trait LockAuthBackend: Send + Sync {
fn authenticate(&self, request: &AuthRequest) -> AuthOutcome;
fn close_session(&self, auth_session_id: Option<&str>) -> Result<()>;
}
impl<T: AuthBackend + ?Sized> LockAuthBackend for T {
fn authenticate(&self, request: &AuthRequest) -> AuthOutcome {
AuthBackend::authenticate(self, request)
}
fn close_session(&self, auth_session_id: Option<&str>) -> Result<()> {
AuthBackend::close_session(self, auth_session_id)
}
}