Switched from bcrypt to argon
This commit is contained in:
parent
ff5f294dae
commit
fb205cd397
|
@ -29,7 +29,7 @@ mime_guess = { version = "2.0.3", optional = true }
|
||||||
sled = { version = "0.34.6", optional = true }
|
sled = { version = "0.34.6", optional = true }
|
||||||
bincode = { version = "1.3.1", optional = true }
|
bincode = { version = "1.3.1", optional = true }
|
||||||
serde = { version = "1.0", optional = true }
|
serde = { version = "1.0", optional = true }
|
||||||
bcrypt = { version = "0.9", optional = true }
|
rust-argon2 = { version = "0.8.2", optional = true }
|
||||||
crc32fast = { version = "1.2.1", optional = true }
|
crc32fast = { version = "1.2.1", optional = true }
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub enum UserManagerError {
|
||||||
DatabaseError(sled::Error),
|
DatabaseError(sled::Error),
|
||||||
DatabaseTransactionError(sled::transaction::TransactionError),
|
DatabaseTransactionError(sled::transaction::TransactionError),
|
||||||
DeserializeError(bincode::Error),
|
DeserializeError(bincode::Error),
|
||||||
BcryptError(bcrypt::BcryptError),
|
Argon2Error(argon2::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<sled::Error> for UserManagerError {
|
impl From<sled::Error> for UserManagerError {
|
||||||
|
@ -52,9 +52,9 @@ impl From<bincode::Error> for UserManagerError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<bcrypt::BcryptError> for UserManagerError {
|
impl From<argon2::Error> for UserManagerError {
|
||||||
fn from(error: bcrypt::BcryptError) -> Self {
|
fn from(error: argon2::Error) -> Self {
|
||||||
Self::BcryptError(error)
|
Self::Argon2Error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ impl std::error::Error for UserManagerError {
|
||||||
Self::DatabaseError(e) => Some(e),
|
Self::DatabaseError(e) => Some(e),
|
||||||
Self::DatabaseTransactionError(e) => Some(e),
|
Self::DatabaseTransactionError(e) => Some(e),
|
||||||
Self::DeserializeError(e) => Some(e),
|
Self::DeserializeError(e) => Some(e),
|
||||||
Self::BcryptError(e) => Some(e),
|
Self::Argon2Error(e) => Some(e),
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,8 +83,8 @@ impl std::fmt::Display for UserManagerError {
|
||||||
write!(f, "Error accessing the user database: {}", e),
|
write!(f, "Error accessing the user database: {}", e),
|
||||||
Self::DeserializeError(e) =>
|
Self::DeserializeError(e) =>
|
||||||
write!(f, "Recieved messy data from database, possible corruption: {}", e),
|
write!(f, "Recieved messy data from database, possible corruption: {}", e),
|
||||||
Self::BcryptError(e) =>
|
Self::Argon2Error(e) =>
|
||||||
write!(f, "Bcrypt Error, likely malformed password hash, possible database corruption: {}", e),
|
write!(f, "Argon2 Error, likely malformed password hash, possible database corruption: {}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,7 +259,7 @@ impl<UserData: Serialize + DeserializeOwned> SignedInUser<UserData> {
|
||||||
try_password: impl AsRef<[u8]>
|
try_password: impl AsRef<[u8]>
|
||||||
) -> Result<bool> {
|
) -> Result<bool> {
|
||||||
if let Some(hash) = &self.inner.pass_hash {
|
if let Some(hash) = &self.inner.pass_hash {
|
||||||
Ok(bcrypt::verify(try_password, hash.as_str())?)
|
Ok(argon2::verify_encoded(hash.as_str(), try_password.as_ref())?)
|
||||||
} else {
|
} else {
|
||||||
Err(super::UserManagerError::PasswordNotSet)
|
Err(super::UserManagerError::PasswordNotSet)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue