feat: wire-in key id on registration and key rotation flows - #8164
Conversation
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE This PR wires the user-key id through V2 registration finish, Code Review DetailsNo blocking findings.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8164 +/- ##
===========================================
+ Coverage 15.10% 67.53% +52.42%
===========================================
Files 1417 2317 +900
Lines 61422 100561 +39139
Branches 4901 9051 +4150
===========================================
+ Hits 9279 67911 +58632
+ Misses 51978 30358 -21620
- Partials 165 2292 +2127 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| /// A key rotation will set a new key id. Account registrations will carry a key id. | ||
| /// </summary> | ||
| [MaxLength(32)] | ||
| [KeyId] |
There was a problem hiding this comment.
❓ Why do we need this on entity ? In other cases, this is used by EF to generate correct column types, but not here.
There was a problem hiding this comment.
Makes sense, I'll remove it in a follow-up PR given this is already approved.
| /// Key id of the user key wrapped by <see cref="KeyConnectorKeyWrappedUserKey"/>, when the client | ||
| /// supplied it. | ||
| /// </summary> | ||
| public KeyId? ContainedKeyId { get; init; } |
There was a problem hiding this comment.
❓ Why not name it, for what it is: UserKeyId ?
There was a problem hiding this comment.
On safe primitives, the value is called ContainedKeyId. Eventually, when we replace the kc-keywrapped-user-key with a safe primitive version, the value is called, we will drop this value and use the contained key id that is in the kc-wrapped-user-key:
https://github.com/bitwarden/sdk-internal/blob/23383b7c0ac01667a0ef78257230c1ceb030b07c/crates/bitwarden-crypto/src/safe/password_protected_key_envelope.rs#L273
Essentially, in the current state this is that same value, just not placed on the wrapped key object.
| /// <see cref="IsV2Request"/>. | ||
| /// </summary> | ||
| [KeyId] | ||
| public string? ContainedKeyId { get; init; } |
There was a problem hiding this comment.
❓ Why not name it, for what it is: UserKeyId ?
There was a problem hiding this comment.
(See other comment)
ike-kottlowski
left a comment
There was a problem hiding this comment.
Just a question about model ownership
There was a problem hiding this comment.
🎨 : do we want to move this to KM ownership?
There was a problem hiding this comment.
I agree, except that we use it for a sub request model, but also a top level request model for JIT crypto init
. We should split this, and auth should still own a JIT crypto init request.Do you agree with this split @ike-kottlowski ?
Wire in the different Key-Id flows to write the key id. A new endpoint is added for backfilling the key id, and the v2 registration flows gain the key id as an optional property, that is set if presented. Further, the key rotation endpoints gain it as an optional property.