Skip to content

Auth/pm 35392/master password service foundation#7530

Merged
enmande merged 29 commits intomainfrom
auth/pm-35392/master-password-service-foundation
Apr 29, 2026
Merged

Auth/pm 35392/master password service foundation#7530
enmande merged 29 commits intomainfrom
auth/pm-35392/master-password-service-foundation

Conversation

@enmande
Copy link
Copy Markdown
Contributor

@enmande enmande commented Apr 22, 2026

🎟️ Tracking

PM-35392

📔 Objective

Introduces the MasterPasswordService, an orchestrating/coordinating surface for Master Password initial set and update operations.

No call sites are connected as part of this PR. For ease of review, those are specced in detail in connected tickets:

A suite of unit tests has been added for the service.

📸 Screenshots

N/A

@enmande enmande added the ai-review Request a Claude code review label Apr 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 22, 2026

Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed the new MasterPasswordService foundation (interface, implementation, four data carriers, DI registration, repository TODO comments, and unit tests). The change introduces a single coordinating surface for master-password set/update flows with a Prepare/Save/Build verb model, validates inputs via ValidateDataForUser per data carrier, and is correctly registered as internal with TryAddScoped. No call sites are wired in this PR, which is consistent with the stated objective and the linked follow-up tickets (PM-35393/4/5).

The crypto contract is preserved: the server stores a hash-of-hash of the client-supplied authentication hash, plaintext master passwords are never received, KDF/salt invariants are enforced on the update paths, and SecurityStamp rotation is correctly composed into all three verb tiers. Known gaps in IUserRepository.SetMasterPassword (no persistence of SecurityStamp and LastPasswordChangeDate) are explicitly disclosed via TODO comments tracked under PM-35501 and PM-34905.

Test coverage is thorough — happy paths, validation failures, KDF rotation directions, salt/KDF independence per field, hydration guards, security-stamp flag behavior across all three tiers, and the deferred-validation contract for Build*. Prior review threads (27 resolved) addressed documentation structure, naming consistency, and OneOf usage; the deferred KDF-consistency check on UpdateExistingPasswordAndKdfData is intentionally scoped to PM-35395.

Code Review Details

No new findings. All previously identified items are either resolved in earlier commits on this PR or tracked in linked Jira tasks (PM-34905, PM-35395, PM-35501).

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

❌ Patch coverage is 99.25373% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.81%. Comparing base (995ccbb) to head (c221552).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...atures/UserMasterPassword/MasterPasswordService.cs 98.91% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7530      +/-   ##
==========================================
+ Coverage   59.25%   63.81%   +4.56%     
==========================================
  Files        2082     2087       +5     
  Lines       91994    92262     +268     
  Branches     8177     8200      +23     
==========================================
+ Hits        54507    58880    +4373     
+ Misses      35549    31356    -4193     
- Partials     1938     2026      +88     

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't begin to say how giddy I am with the changes you've made. I'm so stoked to see that the job you've done is top notch. Thank you 🙏

  1. Do a verbiage check to make sure we are always using set initial or update existing. No concept of "change" anymore as it's ambiguous and we need to be crystal clear about the operations we are performing. This will be feedback to bring into all the rest of the prs as well.
  2. ⛏️ Throughout the MasterPasswordService I left comments on some of the operations happening throughout the set initial and update existing functions and didn't make the comments uniform. Would you mind addressing that? For example the PrepareSetInitialMasterPasswordAsync says // Update time markers on the user but I omitted that on PrepareUpdateExistingMasterPasswordAsync.

Comment thread src/Core/Auth/UserFeatures/UserMasterPassword/MasterPasswordService.cs Outdated
Comment thread src/Infrastructure.Dapper/Repositories/UserRepository.cs
Comment thread src/Infrastructure.EntityFramework/Repositories/UserRepository.cs
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 23, 2026

Logo
Checkmarx One – Scan Summary & Details5cf0c728-c249-423a-8690-2e60712d4a46


New Issues (4) Checkmarx found the following issues in this Pull Request
# Severity Issue Source File / Package Checkmarx Insight
1 MEDIUM CSRF src/Api/Vault/Controllers/CiphersController.cs: 1558
detailsMethod at line 1558 of /src/Api/Vault/Controllers/CiphersController.cs gets a parameter from a user request from id. This parameter value flows ...
Attack Vector
2 MEDIUM CSRF src/Api/Auth/Controllers/AccountsController.cs: 291
detailsMethod at line 291 of /src/Api/Auth/Controllers/AccountsController.cs gets a parameter from a user request from model. This parameter value flow...
Attack Vector
3 MEDIUM CSRF src/Api/Auth/Controllers/AccountsController.cs: 452
detailsMethod at line 452 of /src/Api/Auth/Controllers/AccountsController.cs gets a parameter from a user request from model. This parameter value flow...
Attack Vector
4 MEDIUM CSRF src/Api/Vault/Controllers/CiphersController.cs: 1385
detailsMethod at line 1385 of /src/Api/Vault/Controllers/CiphersController.cs gets a parameter from a user request from id. This parameter value flows ...
Attack Vector

Fixed Issues (1) Great job! The following issues were fixed in this Pull Request
Severity Issue Source File / Package
MEDIUM CSRF src/Api/KeyManagement/Controllers/AccountsKeyManagementController.cs: 173

@enmande enmande marked this pull request as ready for review April 23, 2026 19:57
@enmande enmande requested a review from a team as a code owner April 23, 2026 19:57
Copy link
Copy Markdown
Contributor

@JaredSnider-Bitwarden JaredSnider-Bitwarden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really excellent work here. Most of the items I found were small improvements or nit picks. Thank you for your efforts to build this foundation!

Comment thread src/Core/Auth/UserFeatures/UserMasterPassword/MasterPasswordService.cs Outdated
Comment thread src/Core/Auth/UserFeatures/UserMasterPassword/MasterPasswordService.cs Outdated
Comment thread test/Core.Test/Auth/UserFeatures/UserMasterPassword/MasterPasswordServiceTests.cs Outdated
Copy link
Copy Markdown
Contributor

@JaredSnider-Bitwarden JaredSnider-Bitwarden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stellar work. 🏅 :shipit: !

@sonarqubecloud
Copy link
Copy Markdown

@enmande enmande merged commit c281161 into main Apr 29, 2026
45 checks passed
@enmande enmande deleted the auth/pm-35392/master-password-service-foundation branch April 29, 2026 13:14
jaasen-livefront pushed a commit that referenced this pull request Apr 29, 2026
* feat(mp-service): Add MasterPasswordService foundation.

* docs(mp-service): Resolve incoming comments, document contract.

* feat(mp-service): Add KDF-setting helper and DI.

* test(mp-service): Add tests.

* feat(mp-service): Add enforecement in Build delegate for stamp/validate pw flags, tag data update ticket.

* refactor(mp-service): Align validate/hash/compose/execute pattern.

* test(mp-service): Tighten test assertions.

* refactor(mp-service) chants: unlock and authenticate.

* docs(mp-service): Re-fit some XML doc comment tags for general support.

* docs(mp-service): Address review comment feedback.

* refactor(mp-service): Apply result.Tx handling to all OneOf returns.

* docs(mp-service): Refine unlock vs authentication data comments.

* refactor(mp-service): Rename for saveExistingData (too much existing).

* docs(mp-service): Restore PM-34905 userrepository TODOs.

* refactor(mp-service): Apply test naming clarification.

* refactor(mp-service): Make service internal to Core.

* docs(mp-service): Update method comment formats: what, use when, constraints.

* docs(mp-service): Update interface docs for consistency.

* refactor(mp-service): Rename internal helpers to Apply, add documentation.

* docs(mp-service): Add summary and use-when annotations to data models.

* docs(mp-service): Add annotation preferring non-Build API verbs where possible.

* test(mp-service): Refactor data model tests into discrete files.

* test(mp-service): Address additional coverage cases.

* docs(mp-service): Spelling.

* refactor(mp-service): Extract user security stamp rotation to its own helper.

* docs(mp-service): Clarify authentication hash documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants