pub struct AuthManager { /* private fields */ }Expand description
Manages API key authentication.
Implementations§
Source§impl AuthManager
impl AuthManager
Sourcepub fn with_persistence(path: impl Into<PathBuf>) -> Result<Self>
pub fn with_persistence(path: impl Into<PathBuf>) -> Result<Self>
Create an AuthManager that persists keys to a file.
Sourcepub fn load_from_file(&mut self, path: &Path) -> Result<()>
pub fn load_from_file(&mut self, path: &Path) -> Result<()>
Load keys from a JSON file.
Sourcepub fn generate_key(&mut self, name: &str) -> Result<String>
pub fn generate_key(&mut self, name: &str) -> Result<String>
Generate a new API key.
Returns the full key string (only shown once).
Sourcepub fn revoke_key(&mut self, name: &str) -> Result<()>
pub fn revoke_key(&mut self, name: &str) -> Result<()>
Revoke an API key by name.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AuthManager
impl RefUnwindSafe for AuthManager
impl Send for AuthManager
impl Sync for AuthManager
impl Unpin for AuthManager
impl UnsafeUnpin for AuthManager
impl UnwindSafe for AuthManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more