[PM-42198] feat: Send encryptedByKeyId on cipher requests - #7287
Conversation
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE This PR threads the SDK-reported Code Review DetailsNo findings. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7287 +/- ##
==========================================
+ Coverage 86.23% 86.24% +0.01%
==========================================
Files 894 894
Lines 65445 65524 +79
Branches 9834 9857 +23
==========================================
+ Hits 56438 56514 +76
+ Misses 5512 5508 -4
- Partials 3495 3502 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| assertEquals("mockId-1", result.id) | ||
| assertEquals(request.encryptedFor, result.encryptedFor) | ||
| assertEquals(request.encryptedByKeyId, result.encryptedByKeyId) |
There was a problem hiding this comment.
Just assert the full result
|
|
||
| val cipher = capturedRequest.captured.ciphers.first() | ||
| assertEquals(DEFAULT_CIPHER.encryptedFor, cipher.encryptedFor) | ||
| assertEquals(DEFAULT_CIPHER.encryptedByKeyId, cipher.encryptedByKeyId) |
There was a problem hiding this comment.
Can we just assert the entire cipher is correct
| /** | ||
| * Converts a Bitwarden SDK [Cipher] object to a corresponding | ||
| * [SyncResponseJson.Cipher] object. | ||
| * [CipherJsonRequest] object. |
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-42198
Reference: bitwarden/clients#22444 (wiring only — the enrolment migration in
that PR is out of scope here).
📔 Objective
The SDK reports the id of the key it used to encrypt a vault item. Sending
that to the server allows the write to be validated against the expected key.
The value comes from the SDK's
EncryptionContextand should not besynthesised from app state.
This mirrors the existing
encryptedForplumbing, so every write path thatalready carries an
EncryptionContextpicks it up with no call-site change:create, create in organization, update, cipher key migration, share, bulk
share and CXF import. The new parameter is required with no default, so future
callers have to decide explicitly rather than silently omit the field.
Notes for reviewers
From<EncryptionContext>conversions. The web client'sCipherShareRequestdrops it, which looks unintentional — worth confirming with the author of
clients#22444.
SyncResponseJson.CipherandtoEncryptedNetworkCipherResponseare untouched.📸 Screenshots
N/A — no UI changes.