[PR #2410] [MERGED] [AC-1070] Enforce master password policy on login/unlock #3550

Closed
opened 2025-11-26 23:34:17 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/2410
Author: @shane-melton
Created: 3/9/2023
Status: Merged
Merged: 4/17/2023
Merged by: @shane-melton

Base: masterHead: AC-1070-expand-master-pass-reqs


📝 Commits (10+)

  • 81d5f94 [AC-1070] Add EnforceOnLogin property to MasterPasswordPolicyOptions
  • 8c3a1af [AC-1070] Add MasterPasswordPolicy property to Identity responses
  • 3b0e6c7 [AC-1070] Add policy service dependency to auth service
  • 721db09 [AC-1070] Introduce logic to evaluate master password after successful login
  • d208bc8 [AC-1070] Add optional ForcePasswordResetReason to profile / state service
  • c2284e1 [AC-1070] Save ForcePasswordResetReason to state when a weak master password is found during login
  • 723df74 [AC-1070] Check for a saved ForcePasswordReset reason on TabsPage load force show the update password page
  • 7246e18 [AC-1070] Make InitAsync virtual
  • 4bb4d59 [AC-1070] Modify UpdateTempPassword page appearance
  • 1d767fe [AC-1070] Add update password method to Api service

📊 Changes

23 files changed (+379 additions, -33 deletions)

View changed files

📝 src/App/App.xaml.cs (+8 -0)
📝 src/App/Pages/Accounts/BaseChangePasswordViewModel.cs (+3 -6)
📝 src/App/Pages/Accounts/LockPageViewModel.cs (+47 -1)
📝 src/App/Pages/Accounts/UpdateTempPasswordPage.xaml (+35 -1)
📝 src/App/Pages/Accounts/UpdateTempPasswordPageViewModel.cs (+93 -11)
📝 src/App/Pages/TabsPage.cs (+10 -0)
📝 src/App/Resources/AppResources.Designer.cs (+18 -0)
📝 src/App/Resources/AppResources.resx (+6 -0)
📝 src/Core/Abstractions/IApiService.cs (+2 -1)
📝 src/Core/Abstractions/IStateService.cs (+2 -0)
📝 src/Core/Constants.cs (+1 -0)
📝 src/Core/Models/Domain/Account.cs (+2 -0)
src/Core/Models/Domain/ForcePasswordResetReason.cs (+16 -0)
📝 src/Core/Models/Domain/MasterPasswordPolicyOptions.cs (+1 -0)
src/Core/Models/Request/PasswordRequest.cs (+10 -0)
📝 src/Core/Models/Response/IdentityTokenResponse.cs (+4 -1)
📝 src/Core/Models/Response/IdentityTwoFactorResponse.cs (+2 -0)
src/Core/Models/Response/VerifyMasterPasswordResponse.cs (+9 -0)
📝 src/Core/Services/ApiService.cs (+8 -3)
📝 src/Core/Services/AuthService.cs (+75 -4)

...and 3 more files

📄 Description

Type of change

  • Bug fix
  • New feature development
  • Tech debt (refactoring, code cleanup, dependency upgrades, etc)
  • Build/deploy pipeline (DevOps)
  • Other

Objective

Implement new functionality to evaluate a master password on login if the new option to enforce on login is enabled. If enabled, whenever a user logs in, their master password will be evaluated against the organization's password requirements. If it fails the requirements, the user will be redirected to the update password page and forced to update to a new master password that meets the requirements. The same requirements are also checked during an a vault unlock with master password to ensure existing SSO members are also compliant with the organization's policy.

Required server PR can be found here: https://github.com/bitwarden/server/pull/2714
Clients repo PR with similar functionality for other clients: https://github.com/bitwarden/clients/pull/4795

Code changes

Forcing Password Reset

  • src/App/App.xaml.cs: Listen for new forceUpdatePassword command to navigate to the update password page. Similar to the convertAccountToKeyConnector command.

  • src/App/Pages/TabsPage.cs: On page load, check if there is a forceResetPasswordReason saved to the account's state. If so, fire the forceUpdatePassword command to navigate to the update password page. This is to prevent users from skipping the update password page by restarting the app.

Model Changes

  • src/Core/Models/Domain/MasterPasswordPolicyOptions.cs: Add the new EnforceOnLogin flag that is now available on the master password policy data.

  • src/Core/Models/Response/IdentityTokenResponse.cs: Add MasterPasswordPolicy field that is now returned in the response.

  • src/Core/Models/Response/IdentityTwoFactorResponse.cs: Same as above.

  • src/Core/Models/Response/VerifyMasterPasswordResponse.cs: New response model that is returned when a user verifies their master password with the server that includes the master password policy for that user (during a vault unlock).

Service Changes

  • src/Core/Abstractions/IStateService.cs: Add methods to get/set an accounts forcePasswordResetReason. The auth service will set the value after successful authentication and the password is "weak". It can then be fetched in the TabsPage.cs to check if the user should be forced to update their password.

  • src/Core/Services/AuthService.cs: Bulk of the logic change. During password login, the master password is evaluated using the master password policy returned by the Identity response. If the password does not meet requirements, save the reason to the account state to force a password update. Additional logic is in place to support 2FA login flow.

  • src/Core/Abstractions/IApiService.cs: Add method to update the user's password

Page Changes

  • src/App/Pages/Accounts/UpdateTempPasswordPage.xaml: Update the warning text to depend on the reason for the password reset. Conditionally show a new "Current master password" field if updating a weak master password (not required for admin password resets)

  • src/App/Pages/Accounts/UpdateTempPasswordPageViewModel.cs: Add logic to support updating both admin reset passwords and weak master passwords depending on the reason the user is on the page.

Screenshots

image

Before you submit

  • Please check for formatting errors (dotnet format --verify-no-changes) (required)
  • Please add unit tests where it makes sense to do so (encouraged but not required)
  • If this change requires a documentation update - notify the documentation team
  • If this change has particular deployment requirements - notify the DevOps team

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/2410 **Author:** [@shane-melton](https://github.com/shane-melton) **Created:** 3/9/2023 **Status:** ✅ Merged **Merged:** 4/17/2023 **Merged by:** [@shane-melton](https://github.com/shane-melton) **Base:** `master` ← **Head:** `AC-1070-expand-master-pass-reqs` --- ### 📝 Commits (10+) - [`81d5f94`](https://github.com/bitwarden/android/commit/81d5f94af85fc555c7a8fa31e942c7a7cd37a59d) [AC-1070] Add EnforceOnLogin property to MasterPasswordPolicyOptions - [`8c3a1af`](https://github.com/bitwarden/android/commit/8c3a1af46b484210633c635fc98a2b4889f0a25e) [AC-1070] Add MasterPasswordPolicy property to Identity responses - [`3b0e6c7`](https://github.com/bitwarden/android/commit/3b0e6c7051607d539ce57efa4d167e6f689db60c) [AC-1070] Add policy service dependency to auth service - [`721db09`](https://github.com/bitwarden/android/commit/721db0974de3d4bfde78d7920ca051bd1e774a3c) [AC-1070] Introduce logic to evaluate master password after successful login - [`d208bc8`](https://github.com/bitwarden/android/commit/d208bc82e532841908ebc06a08f717dede7dc2fc) [AC-1070] Add optional ForcePasswordResetReason to profile / state service - [`c2284e1`](https://github.com/bitwarden/android/commit/c2284e1a3b5176da87ae8d84fa2121a3dde16ac6) [AC-1070] Save ForcePasswordResetReason to state when a weak master password is found during login - [`723df74`](https://github.com/bitwarden/android/commit/723df740783e97f39c04a6bb4c98e5a46b129e6d) [AC-1070] Check for a saved ForcePasswordReset reason on TabsPage load force show the update password page - [`7246e18`](https://github.com/bitwarden/android/commit/7246e188ad4ce20b89560af4f627bb7892ac23c3) [AC-1070] Make InitAsync virtual - [`4bb4d59`](https://github.com/bitwarden/android/commit/4bb4d59311ed23b01dee6ab5a6a3fa1063e47649) [AC-1070] Modify UpdateTempPassword page appearance - [`1d767fe`](https://github.com/bitwarden/android/commit/1d767feb538d7f34bf7ed57e117326b0d6f58e65) [AC-1070] Add update password method to Api service ### 📊 Changes **23 files changed** (+379 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `src/App/App.xaml.cs` (+8 -0) 📝 `src/App/Pages/Accounts/BaseChangePasswordViewModel.cs` (+3 -6) 📝 `src/App/Pages/Accounts/LockPageViewModel.cs` (+47 -1) 📝 `src/App/Pages/Accounts/UpdateTempPasswordPage.xaml` (+35 -1) 📝 `src/App/Pages/Accounts/UpdateTempPasswordPageViewModel.cs` (+93 -11) 📝 `src/App/Pages/TabsPage.cs` (+10 -0) 📝 `src/App/Resources/AppResources.Designer.cs` (+18 -0) 📝 `src/App/Resources/AppResources.resx` (+6 -0) 📝 `src/Core/Abstractions/IApiService.cs` (+2 -1) 📝 `src/Core/Abstractions/IStateService.cs` (+2 -0) 📝 `src/Core/Constants.cs` (+1 -0) 📝 `src/Core/Models/Domain/Account.cs` (+2 -0) ➕ `src/Core/Models/Domain/ForcePasswordResetReason.cs` (+16 -0) 📝 `src/Core/Models/Domain/MasterPasswordPolicyOptions.cs` (+1 -0) ➕ `src/Core/Models/Request/PasswordRequest.cs` (+10 -0) 📝 `src/Core/Models/Response/IdentityTokenResponse.cs` (+4 -1) 📝 `src/Core/Models/Response/IdentityTwoFactorResponse.cs` (+2 -0) ➕ `src/Core/Models/Response/VerifyMasterPasswordResponse.cs` (+9 -0) 📝 `src/Core/Services/ApiService.cs` (+8 -3) 📝 `src/Core/Services/AuthService.cs` (+75 -4) _...and 3 more files_ </details> ### 📄 Description ## Type of change - [ ] Bug fix - [X] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ## Objective Implement new functionality to evaluate a master password on login if the new option to enforce on login is enabled. If enabled, whenever a user logs in, their master password will be evaluated against the organization's password requirements. If it fails the requirements, the user will be redirected to the update password page and forced to update to a new master password that meets the requirements. The same requirements are also checked during an a vault unlock with master password to ensure existing SSO members are also compliant with the organization's policy. ## Related PRs Required server PR can be found here: https://github.com/bitwarden/server/pull/2714 Clients repo PR with similar functionality for other clients: https://github.com/bitwarden/clients/pull/4795 ## Code changes ### Forcing Password Reset * **src/App/App.xaml.cs:** Listen for new `forceUpdatePassword` command to navigate to the update password page. Similar to the `convertAccountToKeyConnector` command. * **src/App/Pages/TabsPage.cs:** On page load, check if there is a `forceResetPasswordReason` saved to the account's state. If so, fire the `forceUpdatePassword` command to navigate to the update password page. This is to prevent users from skipping the update password page by restarting the app. ### Model Changes * **src/Core/Models/Domain/MasterPasswordPolicyOptions.cs:** Add the new `EnforceOnLogin` flag that is now available on the master password policy data. * **src/Core/Models/Response/IdentityTokenResponse.cs:** Add `MasterPasswordPolicy` field that is now returned in the response. * **src/Core/Models/Response/IdentityTwoFactorResponse.cs:** Same as above. * **src/Core/Models/Response/VerifyMasterPasswordResponse.cs:** New response model that is returned when a user verifies their master password with the server that includes the master password policy for that user (during a vault unlock). ### Service Changes * **src/Core/Abstractions/IStateService.cs:** Add methods to get/set an accounts `forcePasswordResetReason`. The auth service will set the value after successful authentication and the password is "weak". It can then be fetched in the `TabsPage.cs` to check if the user should be forced to update their password. * **src/Core/Services/AuthService.cs:** Bulk of the logic change. During password login, the master password is evaluated using the master password policy returned by the Identity response. If the password does not meet requirements, save the reason to the account state to force a password update. Additional logic is in place to support 2FA login flow. * **src/Core/Abstractions/IApiService.cs:** Add method to update the user's password ### Page Changes * **src/App/Pages/Accounts/UpdateTempPasswordPage.xaml:** Update the warning text to depend on the reason for the password reset. Conditionally show a new "Current master password" field if updating a weak master password (not required for admin password resets) * **src/App/Pages/Accounts/UpdateTempPasswordPageViewModel.cs:** Add logic to support updating both admin reset passwords and weak master passwords depending on the reason the user is on the page. ## Screenshots <img width="417" alt="image" src="https://user-images.githubusercontent.com/8764515/223889912-31e614fc-3c94-42a4-8a8c-19bacd3a9178.png"> ## Before you submit - Please check for formatting errors (`dotnet format --verify-no-changes`) (required) - Please add **unit tests** where it makes sense to do so (encouraged but not required) - If this change requires a **documentation update** - notify the documentation team - If this change has particular **deployment requirements** - notify the DevOps team --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-26 23:34:17 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#3550