pub mod middleware; mod principal; use crate::error::Error; use async_trait::async_trait; pub use principal::{AppToken, Principal, PrincipalType}; #[async_trait] pub trait AuthenticationProvider: Send + Sync + 'static { async fn get_principals(&self) -> Result, crate::Error>; async fn get_principal(&self, id: &str) -> Result, crate::Error>; async fn remove_principal(&self, id: &str) -> Result<(), crate::Error>; async fn insert_principal(&self, user: Principal, overwrite: bool) -> Result<(), crate::Error>; async fn validate_password( &self, user_id: &str, password: &str, ) -> Result, Error>; async fn validate_app_token( &self, user_id: &str, token: &str, ) -> Result, Error>; /// Returns a token identifier async fn add_app_token( &self, user_id: &str, name: String, token: String, ) -> Result; async fn remove_app_token(&self, user_id: &str, token_id: &str) -> Result<(), Error>; async fn get_app_tokens(&self, principal: &str) -> Result, Error>; async fn add_membership(&self, principal: &str, member_of: &str) -> Result<(), Error>; async fn remove_membership(&self, principal: &str, member_of: &str) -> Result<(), Error>; async fn list_members(&self, principal: &str) -> Result, Error>; } pub use middleware::AuthenticationMiddleware;