-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Allow enforcing password change for a user after reset by admin (root/domain) #12294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #12294 +/- ##
============================================
+ Coverage 17.46% 17.49% +0.03%
- Complexity 15516 15569 +53
============================================
Files 5913 5915 +2
Lines 529385 529767 +382
Branches 64679 64701 +22
============================================
+ Hits 92448 92708 +260
- Misses 426518 426603 +85
- Partials 10419 10456 +37
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@blueorangutan package |
|
@sudo87 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 16086 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements a feature to enforce password changes for normal users after an admin-initiated password reset. When an admin resets a user's password, they can require the user to change it upon next login. The user is then redirected to a forced password change page and has limited API access until the password is updated.
Key Changes:
- Added
passwordChangeRequiredboolean parameter to theupdateUserAPI command, allowing admins to flag users for mandatory password change - Introduced a new UI route
/user/forceChangePasswordwith a dedicated component that restricts users to password change until completed - Implemented navigation guards and API restrictions to limit users to essential APIs (login, logout, updateUser, listUsers, listApis) when password change is required
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
ui/src/views/iam/ForceChangePassword.vue |
New component for forced password change page with form validation and success state |
ui/src/views/iam/ChangeUserPassword.vue |
Added checkbox for admins to require password change on next login |
ui/src/store/mutation-types.js |
Added PASSWORD_CHANGE_REQUIRED constant for state management |
ui/src/store/modules/user.js |
Added state and mutations for password change requirement flag, loads user info with limited APIs when flag is set |
ui/src/store/getters.js |
Added getter for passwordChangeRequired state |
ui/src/permission.js |
Added navigation guards to redirect users to force change password page when required |
ui/src/config/router.js |
Registered new forceChangePassword route under user path |
ui/public/locales/en.json |
Added localization strings for password change UI |
server/src/main/java/com/cloud/user/AccountManagerImpl.java |
Added logic to set/remove passwordChangeRequired user detail, loads user details during authentication |
server/src/main/java/com/cloud/api/query/vo/UserAccountJoinVO.java |
Added passwordChangeRequired field to join view object |
server/src/main/java/com/cloud/api/query/dao/UserAccountJoinDaoImpl.java |
Maps passwordChangeRequired to user response |
server/src/main/java/com/cloud/api/ApiServer.java |
Sets passwordChangeRequired in login session when user detail is present |
plugins/api/discovery/src/main/java/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java |
Restricts API list to essential APIs when user requires password change |
plugins/api/discovery/src/test/java/org/apache/cloudstack/discovery/ApiDiscoveryTest.java |
Updated test setup to mock getUserAccountById method |
engine/schema/src/main/resources/META-INF/db/views/cloud.user_view.sql |
Added LEFT JOIN to user_details table for PasswordChangeRequired value |
engine/schema/src/main/java/org/apache/cloudstack/resourcedetail/UserDetailVO.java |
Added PasswordChangeRequired constant |
api/src/main/java/org/apache/cloudstack/api/response/UserResponse.java |
Added passwordChangeRequired field to user API response |
api/src/main/java/org/apache/cloudstack/api/response/LoginCmdResponse.java |
Added passwordChangeRequired field to login API response |
api/src/main/java/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java |
Added passwordChangeRequired parameter to update user command |
api/src/main/java/org/apache/cloudstack/api/ApiConstants.java |
Added PASSWORD_CHANGE_REQUIRED API constant |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
api/src/main/java/org/apache/cloudstack/api/response/UserResponse.java
Outdated
Show resolved
Hide resolved
...ins/api/discovery/src/main/java/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
Outdated
Show resolved
Hide resolved
api/src/main/java/org/apache/cloudstack/api/response/UserResponse.java
Outdated
Show resolved
Hide resolved
api/src/main/java/org/apache/cloudstack/api/response/LoginCmdResponse.java
Outdated
Show resolved
Hide resolved
...ins/api/discovery/src/main/java/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
Outdated
Show resolved
Hide resolved
|
@blueorangutan package |
|
@sudo87 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 16095 |
|
@blueorangutan package |
|
@sudo87 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 16097 |
…wd flow for passwordchangerequired
...ins/api/discovery/src/main/java/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
Outdated
Show resolved
Hide resolved
...ins/api/discovery/src/main/java/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated 17 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @Before | ||
| public void setup() { | ||
| discoveryServiceSpy.s_apiNameDiscoveryResponseMap = apiNameDiscoveryResponseMapMock; | ||
| discoveryServiceSpy._apiAccessCheckers = apiAccessCheckersMock; | ||
|
|
||
| Mockito.when(discoveryServiceSpy._apiAccessCheckers.iterator()).thenReturn(Arrays.asList(apiCheckerMock).iterator()); | ||
| Mockito.when(mockUserAccount.getDetails()).thenReturn(null); | ||
| Mockito.when(accountServiceMock.getUserAccountById(anyLong())).thenReturn(mockUserAccount); | ||
| } |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test setup mocks getUserAccountById to return null for user details, but there's no test case that verifies the new password change required functionality. The new logic in ApiDiscoveryServiceImpl that restricts APIs when passwordchangerequired is true is not covered by any test. Consider adding test cases for: 1) user with passwordchangerequired=true should only get limited APIs, and 2) user with passwordchangerequired=false should follow normal flow.
| private void updatePasswordChangeRequired(User caller, UpdateUserCmd updateUserCmd, UserVO user) { | ||
| if (StringUtils.isNotBlank(updateUserCmd.getPassword())) { | ||
| boolean isCallerSameAsUser = user.getId() == caller.getId(); | ||
| boolean isPasswordResetRequired = updateUserCmd.isPasswordChangeRequired() && !isCallerSameAsUser; | ||
| // Admins only can enforce passwordChangeRequired for user | ||
| if ((isRootAdmin(caller.getAccountId()) || isDomainAdmin(caller.getAccountId()))) { | ||
| if (isPasswordResetRequired) { | ||
| _userDetailsDao.addDetail(user.getId(), PasswordChangeRequired, "true", false); | ||
| } | ||
| } | ||
|
|
||
| // Remove passwordChangeRequired if user updating own pwd or admin has not enforced it | ||
| if (isCallerSameAsUser || !isPasswordResetRequired) { | ||
| _userDetailsDao.removeDetail(user.getId(), PasswordChangeRequired); | ||
| } | ||
| } | ||
| } |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new updatePasswordChangeRequired method and its logic for handling passwordchangerequired parameter are not covered by any test cases. Consider adding tests to verify: 1) password change required is set when admin changes user password with the flag, 2) flag is removed when user changes own password, 3) flag is removed when admin changes password without the flag, and 4) admins cannot set the flag for themselves or other admins.
...ins/api/discovery/src/main/java/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
Show resolved
Hide resolved
|
@blueorangutan package |
|
@sudo87 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16106 |
Description
This PR introduces enforcement of password changes for users upon login after an admin-initiated reset.
API changes:
[ "login", "logout", "updateUser", "listUsers", "listApis" ]UI
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
Screen.Recording.2025-12-18.at.4.11.45.PM.mov
How Has This Been Tested?
How did you try to break this feature and the system with this change?