Skip to content

PM-40295: bug: Add MP Policy checks on vault unlock#7165

Open
david-livefront wants to merge 1 commit into
mainfrom
PM-40295-mp-policy-on-unlock
Open

PM-40295: bug: Add MP Policy checks on vault unlock#7165
david-livefront wants to merge 1 commit into
mainfrom
PM-40295-mp-policy-on-unlock

Conversation

@david-livefront

@david-livefront david-livefront commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

🎟️ Tracking

PM-40295

📔 Objective

This PR moves all the MasterPassword Policy logic into a new class and adds the policy check on vault unlock as well as login.

@david-livefront
david-livefront requested a review from a team as a code owner July 14, 2026 19:25
@david-livefront david-livefront changed the title PM-40295: Add MP Policy checks on vault unlock PM-40295: bug: Add MP Policy checks on vault unlock Jul 14, 2026
@github-actions github-actions Bot added app:password-manager Bitwarden Password Manager app context t:bug Change Type - Bug labels Jul 14, 2026
@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

This PR extracts master password policy logic out of AuthRepositoryImpl into a new PasswordPolicyManager/PasswordPolicyManagerImpl, wires it through DI, and adds the policy check on vault unlock (VaultLockManagerImpl.processMasterPassword) in addition to login. AuthRepository now delegates to PasswordPolicyManager, so existing callers of passwordPolicies, passwordResetReason, getPasswordStrength, and validatePasswordAgainstPolicies remain source-compatible. Tests were moved alongside the new manager and unlock/logout paths gained corresponding storePasswordToCheck/removePasswordToCheck verifications. The extraction is clean and the validation logic is preserved verbatim.

Code Review Details
  • ❓ : Cached plaintext password is no longer cleared on user switch (only on lock/logout), lengthening the in-memory retention window for a backgrounded account
    • app/src/main/kotlin/com/x8bit/bitwarden/data/platform/manager/policy/PasswordPolicyManagerImpl.kt:101

* The password that needs to be checked against any organization policies before
* the user can complete the login flow. This value is stored using the user ID.
*/
private val mutablePasswordsToCheckFlow = MutableStateFlow(value = mapOf<String, String>())

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@vvolkgang Once the KeystoreManager is ready, I would like to encrypt this data.

@david-livefront
david-livefront force-pushed the PM-40295-mp-policy-on-unlock branch from b5a621e to b29e1e3 Compare July 14, 2026 19:29
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.63158% with 45 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.93%. Comparing base (c6f7a47) to head (bd2e4c2).

Files with missing lines Patch % Lines
...atform/manager/policy/PasswordPolicyManagerImpl.kt 39.43% 25 Missing and 18 partials ⚠️
...twarden/data/vault/manager/VaultLockManagerImpl.kt 89.47% 0 Missing and 2 partials ⚠️

❗ There is a different number of reports uploaded between BASE (c6f7a47) and HEAD (bd2e4c2). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (c6f7a47) HEAD (bd2e4c2)
app-ui-platform 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #7165       +/-   ##
===========================================
- Coverage   86.19%   69.93%   -16.26%     
===========================================
  Files         884      990      +106     
  Lines       64674    66712     +2038     
  Branches     9681     9709       +28     
===========================================
- Hits        55745    46656     -9089     
- Misses       5456    17035    +11579     
+ Partials     3473     3021      -452     
Flag Coverage Δ
app-data 17.68% <51.57%> (-0.08%) ⬇️
app-ui-auth-tools 18.78% <1.05%> (+<0.01%) ⬆️
app-ui-platform ?
app-ui-vault 27.35% <0.00%> (-0.01%) ⬇️
authenticator 6.10% <0.00%> (-0.01%) ⬇️
lib-core-network-bridge 4.01% <0.00%> (-0.02%) ⬇️
lib-data-ui 1.15% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@david-livefront
david-livefront force-pushed the PM-40295-mp-policy-on-unlock branch 2 times, most recently from 1391fde to 68addd6 Compare July 17, 2026 18:46
@david-livefront
david-livefront force-pushed the PM-40295-mp-policy-on-unlock branch from 68addd6 to bd2e4c2 Compare July 21, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app:password-manager Bitwarden Password Manager app context t:bug Change Type - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant