Skip to content

Commit 9ebfeb3

Browse files
committed
Match encrypted for name across implementations
1 parent 2f18679 commit 9ebfeb3

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

crates/bitwarden-vault/src/cipher/cipher.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ pub enum CipherRepromptType {
6969
#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
7070
#[cfg_attr(feature = "wasm", derive(Tsify), tsify(into_wasm_abi, from_wasm_abi))]
7171
pub struct EncryptionContext {
72-
pub user_id: Uuid,
72+
/// The Id of the user that encrypted the cipher. It should always represent a UserId, even for
73+
/// Organization-owned ciphers
74+
pub encrypted_for: Uuid,
7375
pub cipher: Cipher,
7476
}
7577

crates/bitwarden-vault/src/cipher/cipher_client.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ impl CiphersClient {
3434
}
3535

3636
let cipher = key_store.encrypt(cipher_view)?;
37-
Ok(EncryptionContext { cipher, user_id })
37+
Ok(EncryptionContext {
38+
cipher,
39+
encrypted_for: user_id,
40+
})
3841
}
3942

4043
pub fn decrypt(&self, cipher: Cipher) -> Result<CipherView, DecryptError> {
@@ -233,7 +236,7 @@ mod tests {
233236
// Assert the cipher has a key, and the attachment is still readable
234237
let EncryptionContext {
235238
cipher: new_cipher,
236-
user_id: _,
239+
encrypted_for: _,
237240
} = client.vault().ciphers().encrypt(view).unwrap();
238241
assert!(new_cipher.key.is_some());
239242

@@ -275,7 +278,7 @@ mod tests {
275278
// Assert the cipher has a key, and the attachment is still readable
276279
let EncryptionContext {
277280
cipher: new_cipher,
278-
user_id: _,
281+
encrypted_for: _,
279282
} = client.vault().ciphers().encrypt(view).unwrap();
280283
assert!(new_cipher.key.is_some());
281284

@@ -322,7 +325,7 @@ mod tests {
322325
.unwrap();
323326
let EncryptionContext {
324327
cipher: new_cipher,
325-
user_id: _,
328+
encrypted_for: _,
326329
} = client.vault().ciphers().encrypt(new_view).unwrap();
327330

328331
let attachment = new_cipher

0 commit comments

Comments
 (0)