[PM-39454] feat(km): add repository methods to set the user key id - #8109
[PM-39454] feat(km): add repository methods to set the user key id#8109quexten wants to merge 3 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## km/user-key-id-03-userkeyid-column #8109 +/- ##
======================================================================
+ Coverage 67.37% 67.38% +0.01%
======================================================================
Files 2303 2303
Lines 100288 100349 +61
Branches 9032 9034 +2
======================================================================
+ Hits 67569 67622 +53
- Misses 30438 30445 +7
- Partials 2281 2282 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
2d23b7d to
bc1d5cc
Compare
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed Code Review DetailsNo findings at or above the reporting threshold. Verified during this pass, no action needed:
Noted, not worth a thread: |
bc1d5cc to
c5ba4f6
Compare
Two ways to write the key id, for two different situations. SetUserKeyId overwrites unconditionally and returns a deferred UpdateUserData delegate, so the write joins the transaction that establishes the user key itself. There the supplied key id is authoritative and whatever was stored before is stale by definition. TrySetUserKeyIdAsync only writes when the column is still null, reporting whether it stored anything. That is the backfill case: an existing account whose key id the server never learned, where a client's claim must not overwrite a value some other flow already established. Also carries the key id on the Core data models the repositories read from — MasterPasswordUnlockData, RegisterFinishData and KeyConnectorKeysData — and moves User_UpdateMasterPassword and User_UpdateMasterPasswordUnlockData here from the schema commit so that each procedure lands with the caller that supplies its parameter. SetMasterPassword applies its key id fill-only, since setting a master password re-wraps the existing user key rather than replacing it: it records a key id the account does not have yet, but never renames one it already has. The COALESCE in User_UpdateMasterPassword and the ??= in the EF path are the same rule, so all four providers agree. Nothing calls these yet; the flows that do come next.
c5ba4f6 to
9202a9c
Compare
Adds methods to set the user-key id on the user table. There is two functions, one to set the id in all cases, and one to set it if not present yet. We do not want to accidentally overwrite it, but in some cases (key rotations) we must overwrite it.