add umbrella crate

This commit is contained in:
Aleksandr 2025-09-20 22:55:40 +03:00
parent d171fc723b
commit fe04530f84
17 changed files with 247 additions and 5 deletions

1
auth/src/lib.rs Normal file
View file

@ -0,0 +1 @@
pub mod passwords;

24
auth/src/passwords.rs Normal file
View file

@ -0,0 +1,24 @@
use eva::auto_impl;
use viendesu_core::types::user::PasswordHash;
/// Passwords generation utility.
#[auto_impl(&, &mut, Arc)]
pub trait Passwords: Send + Sync {
fn verify(&self, hash: &str, cleartext: &str) -> bool;
fn make(&self, cleartext: &str) -> PasswordHash;
}
/// Plaintext passwords, no hashing.
#[derive(Debug, Clone, Copy)]
pub struct Plaintext;
impl Passwords for Plaintext {
fn verify(&self, hash: &str, cleartext: &str) -> bool {
hash == cleartext
}
fn make(&self, cleartext: &str) -> PasswordHash {
cleartext.parse().unwrap()
}
}