update taskell
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
30a20873ea
commit
888b2cbe80
|
@ -45,14 +45,15 @@ pub async fn get_server_salt(socket: &mut TlsStream<TcpStream>) -> std::io::Resu
|
|||
io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
"Failed getting generated server Salt, received an invalid message.",
|
||||
)
|
||||
)
|
||||
})?;
|
||||
|
||||
/* verify that the salt is actually valid */
|
||||
SaltString::new(salt_raw.as_str()).map_err(|_| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
"Failed getting generated server Salt, received an invalid message.")
|
||||
"Failed getting generated server Salt, received an invalid message.",
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,8 @@ pub async fn req_server_salt(
|
|||
) -> std::io::Result<SaltString> {
|
||||
/* enforce salt_type to be either email or password */
|
||||
assert_eq!(
|
||||
(salt_type == Command::GetEmailSalt) || (salt_type == Command::GetPasswordSalt), true
|
||||
(salt_type == Command::GetEmailSalt) || (salt_type == Command::GetPasswordSalt),
|
||||
true
|
||||
);
|
||||
|
||||
/* generate message to send */
|
||||
|
@ -56,8 +57,8 @@ pub async fn req_server_salt(
|
|||
let salt_raw: String = ret_msg.get_data().map_err(|_| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
"Could not get server salt, received invalid data."
|
||||
)
|
||||
"Could not get server salt, received invalid data.",
|
||||
)
|
||||
})?;
|
||||
|
||||
/* verify that the salt is actually valid */
|
||||
|
@ -65,6 +66,6 @@ pub async fn req_server_salt(
|
|||
io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
format!("Could not get server salt, received invalid salt length."),
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -110,7 +110,8 @@ pub async fn acc_auth(
|
|||
.send(socket)
|
||||
.await;
|
||||
}
|
||||
}; if argon2id
|
||||
};
|
||||
if argon2id
|
||||
.verify_password(&passw_client_hash.as_bytes(), &parsed_passw_hash)
|
||||
.is_err()
|
||||
{
|
||||
|
|
|
@ -49,46 +49,47 @@ pub async fn acc_create(
|
|||
}
|
||||
|
||||
/* get email, password client PHC strings */
|
||||
let (email_client_hash_phc, passw_client_hash_phc) =
|
||||
match (data["email_client_hash_phc"].as_str(), data["passw_client_hash_phc"].as_str()) {
|
||||
(Some(a), Some(b)) => (a, b),
|
||||
_ => {
|
||||
/* received empty PHC strings */
|
||||
return Message::new()
|
||||
.command(Command::Failure)
|
||||
.data("Received empty PHC strings")
|
||||
.send(socket)
|
||||
.await;
|
||||
}
|
||||
};
|
||||
let (email_client_hash_phc, passw_client_hash_phc) = match (
|
||||
data["email_client_hash_phc"].as_str(),
|
||||
data["passw_client_hash_phc"].as_str(),
|
||||
) {
|
||||
(Some(a), Some(b)) => (a, b),
|
||||
_ => {
|
||||
/* received empty PHC strings */
|
||||
return Message::new()
|
||||
.command(Command::Failure)
|
||||
.data("Received empty PHC strings")
|
||||
.send(socket)
|
||||
.await;
|
||||
}
|
||||
};
|
||||
|
||||
let (email_client, passw_client) =
|
||||
match (PasswordHash::new(email_client_hash_phc), PasswordHash::new(passw_client_hash_phc)) {
|
||||
(Ok(a), Ok(b)) => (a, b),
|
||||
_ => {
|
||||
return Message::new()
|
||||
.command(Command::Failure)
|
||||
.data("Received invalid PHC strings")
|
||||
.send(socket)
|
||||
.await;
|
||||
}
|
||||
};
|
||||
let (email_client, passw_client) = match (
|
||||
PasswordHash::new(email_client_hash_phc),
|
||||
PasswordHash::new(passw_client_hash_phc),
|
||||
) {
|
||||
(Ok(a), Ok(b)) => (a, b),
|
||||
_ => {
|
||||
return Message::new()
|
||||
.command(Command::Failure)
|
||||
.data("Received invalid PHC strings")
|
||||
.send(socket)
|
||||
.await;
|
||||
}
|
||||
};
|
||||
|
||||
/* store salt _ONLY_ from the PHC string received,
|
||||
* Note: discard the main hash sent from client after hashing by server */
|
||||
let (email_client_salt, passw_client_salt) =
|
||||
match (email_client.salt, passw_client.salt) {
|
||||
(Some(a), Some(b)) => (a, b),
|
||||
_ => {
|
||||
return Message::new()
|
||||
.command(Command::Failure)
|
||||
.data("Received invalid salts")
|
||||
.send(socket)
|
||||
.await;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
let (email_client_salt, passw_client_salt) = match (email_client.salt, passw_client.salt) {
|
||||
(Some(a), Some(b)) => (a, b),
|
||||
_ => {
|
||||
return Message::new()
|
||||
.command(Command::Failure)
|
||||
.data("Received invalid salts")
|
||||
.send(socket)
|
||||
.await;
|
||||
}
|
||||
};
|
||||
|
||||
/* generate account struct */
|
||||
let mut account: Account = Account {
|
||||
|
@ -107,7 +108,9 @@ pub async fn acc_create(
|
|||
/*
|
||||
* Hash the email and password and store them.
|
||||
* */
|
||||
if let (Some(email_client_hash), Some(passw_client_hash)) = (email_client.hash, passw_client.hash) {
|
||||
if let (Some(email_client_hash), Some(passw_client_hash)) =
|
||||
(email_client.hash, passw_client.hash)
|
||||
{
|
||||
account.email_hash_phc = hash(email_client_hash.to_string());
|
||||
account.passw_hash_phc = hash(passw_client_hash.to_string());
|
||||
} else {
|
||||
|
|
|
@ -35,9 +35,8 @@ pub async fn get_server_salt(
|
|||
.unwrap()
|
||||
{
|
||||
/* parse PHC string */
|
||||
let parsed_phc = PasswordHash::new(row.get(1)).map_err(|_| {
|
||||
format!("Account, {}, corrupted, invalid parsed PHC", username)
|
||||
})?;
|
||||
let parsed_phc = PasswordHash::new(row.get(1))
|
||||
.map_err(|_| format!("Account, {}, corrupted, invalid parsed PHC", username))?;
|
||||
if let Some(salt) = parsed_phc.salt {
|
||||
return Ok(salt.to_string());
|
||||
} else {
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
## In progress
|
||||
|
||||
- create correct modules
|
||||
* [ ] fix weird file naming
|
||||
* [x] fix weird file naming
|
||||
* [ ] fix namespace naming
|
||||
* [ ] remove unneeded MessageType
|
||||
* [x] remove unneeded MessageType
|
||||
* [ ] make server return coded
|
||||
|
||||
## Done
|
||||
|
|
Loading…
Reference in New Issue