add umbrella crate
This commit is contained in:
parent
d171fc723b
commit
fe04530f84
17 changed files with 247 additions and 5 deletions
8
auth/Cargo.toml
Normal file
8
auth/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "viendesu-auth"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
eva.workspace = true
|
||||
viendesu-core.workspace = true
|
1
auth/src/lib.rs
Normal file
1
auth/src/lib.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub mod passwords;
|
24
auth/src/passwords.rs
Normal file
24
auth/src/passwords.rs
Normal 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()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue