wae_authentication/password/
config.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum PasswordHashAlgorithm {
6 Bcrypt,
8}
9
10#[derive(Debug, Clone)]
12pub struct PasswordHashConfig {
13 pub algorithm: PasswordHashAlgorithm,
15 pub bcrypt_cost: u32,
17}
18
19impl Default for PasswordHashConfig {
20 fn default() -> Self {
21 Self { algorithm: PasswordHashAlgorithm::Bcrypt, bcrypt_cost: 12 }
22 }
23}
24
25impl PasswordHashConfig {
26 pub fn new(algorithm: PasswordHashAlgorithm) -> Self {
31 Self { algorithm, ..Default::default() }
32 }
33
34 pub fn with_bcrypt_cost(mut self, cost: u32) -> Self {
39 self.bcrypt_cost = cost.clamp(4, 31);
40 self
41 }
42}