diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-05-03 03:02:15 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-05-03 03:02:15 -0400 |
commit | 20ac7d3d39cc81eee8bcd8dd5caad44fc1cab82d (patch) | |
tree | 4f583bd1a119e86a71d5d232e7dc6098be23df6f | |
parent | aafefa7f344441c709198e16cd07da11b4651a98 (diff) | |
download | rbw-20ac7d3d39cc81eee8bcd8dd5caad44fc1cab82d.tar.gz rbw-20ac7d3d39cc81eee8bcd8dd5caad44fc1cab82d.zip |
pass along the entry's org id when requesting decryption
-rw-r--r-- | src/bin/rbw/commands.rs | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs index 0991f08..51d0453 100644 --- a/src/bin/rbw/commands.rs +++ b/src/bin/rbw/commands.rs @@ -659,6 +659,8 @@ fn find_entry_raw( } fn decrypt_cipher(entry: &rbw::db::Entry) -> anyhow::Result<DecryptedCipher> { + // folder name should always be decrypted with the local key because + // folders are local to a specific user's vault, not the organization let folder = entry .folder .as_ref() @@ -674,7 +676,9 @@ fn decrypt_cipher(entry: &rbw::db::Entry) -> anyhow::Result<DecryptedCipher> { let username = entry .username .as_ref() - .map(|username| crate::actions::decrypt(username, None)) + .map(|username| { + crate::actions::decrypt(username, entry.org_id.as_deref()) + }) .transpose(); let username = match username { Ok(username) => username, @@ -686,7 +690,9 @@ fn decrypt_cipher(entry: &rbw::db::Entry) -> anyhow::Result<DecryptedCipher> { let password = entry .password .as_ref() - .map(|password| crate::actions::decrypt(password, None)) + .map(|password| { + crate::actions::decrypt(password, entry.org_id.as_deref()) + }) .transpose(); let password = match password { Ok(password) => password, @@ -698,7 +704,7 @@ fn decrypt_cipher(entry: &rbw::db::Entry) -> anyhow::Result<DecryptedCipher> { let notes = entry .notes .as_ref() - .map(|notes| crate::actions::decrypt(notes, None)) + .map(|notes| crate::actions::decrypt(notes, entry.org_id.as_deref())) .transpose(); let notes = match notes { Ok(notes) => notes, @@ -710,17 +716,20 @@ fn decrypt_cipher(entry: &rbw::db::Entry) -> anyhow::Result<DecryptedCipher> { let history = entry .history .iter() - .map(|entry| { + .map(|history_entry| { Ok(DecryptedHistoryEntry { - last_used_date: entry.last_used_date.clone(), - password: crate::actions::decrypt(&entry.password, None)?, + last_used_date: history_entry.last_used_date.clone(), + password: crate::actions::decrypt( + &history_entry.password, + entry.org_id.as_deref(), + )?, }) }) .collect::<anyhow::Result<_>>()?; Ok(DecryptedCipher { id: entry.id.clone(), folder, - name: crate::actions::decrypt(&entry.name, None)?, + name: crate::actions::decrypt(&entry.name, entry.org_id.as_deref())?, username, password, notes, |