mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-09-06 01:38:09 +00:00
Update KDF Configuration and processing
- Change default Password Hash KDF Storage from 100_000 to 600_000 iterations - Update Password Hash when the default iteration value is different - Validate password_iterations - Validate client-side KDF to prevent it from being set lower than 100_000
This commit is contained in:
parent
9b7e86efc2
commit
2d8c8e18f7
6 changed files with 35 additions and 15 deletions
|
@ -74,7 +74,7 @@ pub struct UserStampException {
|
|||
/// Local methods
|
||||
impl User {
|
||||
pub const CLIENT_KDF_TYPE_DEFAULT: i32 = 0; // PBKDF2: 0
|
||||
pub const CLIENT_KDF_ITER_DEFAULT: i32 = 100_000;
|
||||
pub const CLIENT_KDF_ITER_DEFAULT: i32 = 600_000;
|
||||
|
||||
pub fn new(email: String) -> Self {
|
||||
let now = Utc::now().naive_utc();
|
||||
|
@ -151,14 +151,16 @@ impl User {
|
|||
/// These routes are able to use the previous stamp id for the next 2 minutes.
|
||||
/// After these 2 minutes this stamp will expire.
|
||||
///
|
||||
pub fn set_password(&mut self, password: &str, allow_next_route: Option<Vec<String>>) {
|
||||
pub fn set_password(&mut self, password: &str, reset_security_stamp: bool, allow_next_route: Option<Vec<String>>) {
|
||||
self.password_hash = crypto::hash_password(password.as_bytes(), &self.salt, self.password_iterations as u32);
|
||||
|
||||
if let Some(route) = allow_next_route {
|
||||
self.set_stamp_exception(route);
|
||||
}
|
||||
|
||||
self.reset_security_stamp()
|
||||
if reset_security_stamp {
|
||||
self.reset_security_stamp()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reset_security_stamp(&mut self) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue