[PM-37886] refactor: Pass keyConnectorKeyWrappedUserKey through LoginUnlockMethod instead of persisting in state#2764
Conversation
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed this refactor that passes Code Review DetailsNo findings. The change is well-scoped, security-positive (reduces persistence of a sensitive wrapped key that is no longer needed after unlock), and comprehensively tested across all three unlock entry points. |
57c6f88 to
934fd0a
Compare
…UnlockMethod instead of persisting in state
934fd0a to
f9ca3ee
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2764 +/- ##
=======================================
Coverage 80.83% 80.84%
=======================================
Files 1018 1018
Lines 64903 64902 -1
=======================================
+ Hits 52463 52467 +4
+ Misses 12440 12435 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
fedemkr
left a comment
There was a problem hiding this comment.
Looks good, just one small ⛏️
🎟️ Tracking
PM-37886
📔 Objective
When a user logs in with key connector, their
keyConnectorKeyWrappedUserKeyis being persisted to the device asencryptedUserKey. For key connector, once the user is logged in and the vault is unlocked, this key is no longer used. As such, it doesn't need to be persisted.Additional context: #2677 (comment)
This updates the key connector flows to pass the
keyConnectorKeyWrappedUserKeyfrom the login response throughLoginUnlockMethod.keyConnector, which can then be used to unlock the vault inAuthRepository.unlockVaultWithKeyConnectorKey().LoginUnlockMethod.keyConnectornow carriesencryptedUserKey: String?populated fromresponse.keyinAuthService.unlockMethod(for:), eliminating the need to read it back from state during unlock.AuthRepository.unlockVaultWithKeyConnectorKeyaccepts a non-optionalencryptedUserKey: Stringparameter directly, removing the redundantgetAccountEncryptionKeysstate read.KeyConnectorService.convertNewUserToKeyConnectorno longer persistsencryptedUserKeyto state (both v1 and v2 paths); thecryptographicState(private key) is still persisted as required for future operations.SingleSignOnProcessornow uses an explicitguard let encryptedUserKeyto trigger the key connector migration dialog for new users, replacing the implicitnoAccountCryptographicStateerror path.