Skip to content

Auth/PM-38811 - KM - Update RotateUserAccountKeysCommand to use MasterPasswordService#7804

Draft
JaredSnider-Bitwarden wants to merge 3 commits into
mainfrom
auth/pm-38811/update-rotate-user-keys-command-to-use-mp-service
Draft

Auth/PM-38811 - KM - Update RotateUserAccountKeysCommand to use MasterPasswordService#7804
JaredSnider-Bitwarden wants to merge 3 commits into
mainfrom
auth/pm-38811/update-rotate-user-keys-command-to-use-mp-service

Conversation

@JaredSnider-Bitwarden

@JaredSnider-Bitwarden JaredSnider-Bitwarden commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-38811
Awaiting merge of #7768 before continuing to testing.

📔 Objective

To finish consolidating KM usages of the MasterPasswordService which centralizes MP change logic in one location as part of the ongoing separation of MP salt & email work.

📸 Screenshots

TODO

…rite

UpdateUserKeyAndEncryptedDataV2Async enumerated a fixed column list and
omitted LastPasswordChangeDate, silently dropping the field on
PostgreSQL/MySQL/SQLite even when callers set it. The MSSQL sproc
User_Update already persists this column, so this aligns EF with the
existing Dapper behavior.
Wires PasswordChangeAndRotateUserAccountKeysAsync to
IMasterPasswordService.PrepareUpdateExistingMasterPasswordAsync
(Prepare* tier from PM-35392), replacing the inline master password
mutation block. RefreshStamp is false so the existing
BaseRotateUserAccountKeysAsync SecurityStamp + V2UpgradeToken logic
remains the sole owner of session-invalidation behavior. The hint is
sourced from the request because a password change can update it.

Closes the parity gap where LastPasswordChangeDate was not set on this
path even though the master password is changing.

Other rotation variants (master-password-only, TDE, Key Connector) are
untouched. Unit tests cover delegation, OneOf failure mapping, and
short-circuit on old-password mismatch.
Extends the existing happy-path integration test to verify the
master-key-wrapped user key, master password hint, master password
hash (rewritten and verifies against the new authentication hash),
and LastPasswordChangeDate are persisted as expected after a
password-change-and-rotate call.
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.54%. Comparing base (837a9dd) to head (5cb9ab2).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7804      +/-   ##
==========================================
+ Coverage   61.15%   65.54%   +4.39%     
==========================================
  Files        2175     2175              
  Lines       96784    96794      +10     
  Branches     8730     8731       +1     
==========================================
+ Hits        59187    63447    +4260     
+ Misses      35487    31146    -4341     
- Partials     2110     2201      +91     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread test/Core.Test/KeyManagement/UserKey/RotateUserAccountKeysCommandTests.cs Dismissed
Comment thread test/Core.Test/KeyManagement/UserKey/RotateUserAccountKeysCommandTests.cs Dismissed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant