Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
3.9 KiB
3.9 KiB
Design
Context
- Emailed reset:
POST /api/admin/users/{id}/resetPassword(mobile-api,@AdminModule("BO_USERS")) runsAdminUserService.resetPassword. That loads the target withloadManaged, which refuses a super admin to a non-super caller, then calls services-system/user/resetAdminPassword. That endpoint:- checks the user is type
A, enabled, and that the email matches; - generates
ValidateUtil.getRandomPasswordString(8); - stores it bcrypt-encoded with
login = N; - emails it.
- checks the user is type
- Generator:
getRandomPasswordStringusesjava.util.Randomover an alphabet without look-alike characters. - Sign-in:
login = Nmakes mobile-api answer every admin call with 403PASSWORD_RESET_REQUIREDuntil/api/admin/auth/first-login. The portal redirects to the change-password page on that code. - Logging: the gateway logs no bodies (spec
gateway-request-logging).
Goals / Non-Goals
Goals: onboard and unlock staff without email; make every generated temporary password unpredictable.
Non-Goals: admin-chosen passwords; ending the user's existing sessions on reset (the emailed reset does not do this today either); a create-form option.
Decisions
- SecureRandom at the shared generator.
getRandomPasswordStringdraws from one staticSecureRandomwithnextInt(alphabet.length()), keeping the same alphabet. This one change covers every caller: the emailed reset, forgot-password, user creation and the new path. - services-system endpoint
POST /user/issueAdminTempPasswordwith body{id}:- It refuses (returns no password) unless the user exists, is type
Aand is enabled. - It generates 12 characters, stores them bcrypt-encoded with
login = N, and returns{"password": "<plain>"}. - It sends no email.
- It sits beside
resetAdminPasswordand is reachable only inside the cluster, through the gateway (/user/**route). - Alternative: add a "don't email" flag to
resetAdminPassword. Rejected: that endpoint also serves the public forgot-password path, and a flag there could be misused.
- It refuses (returns no password) unless the user exists, is type
- mobile-api
POST /api/admin/users/{id}/temporary-passwordinAdminUserController(class-levelBO_USERS), viaAdminUserService.issueTemporaryPassword(id):- It refuses its own account: 400
SELF_NOT_ALLOWED. - It uses
loadManaged: 404 for an unknown user, and 403 for a super admin when the caller is not one. - It refuses a disabled user: 409
USER_DISABLED. - On success it returns
{"password": "..."}withCache-Control: no-store. - It logs only the audit line
temporary password set by <caller> for user <id>, never the password.
- It refuses its own account: 400
- Portal:
- A "Set temporary password" button on
/users/[id], beside the existing reset button. - It opens a confirmation first, then calls a new proxy route that forwards
Cache-Control: no-store. - On success it shows a dialog with the password, a copy button, and the note "Shown once. The user must change it at first sign-in".
- The password lives only in that dialog's React state and is cleared when the dialog closes. It never goes into the URL, storage or logs.
- Refusals show their message on the page.
- A "Set temporary password" button on
- Handover:
docs/deployment.mdsection 10 says staff can be onboarded without email through this action.
Risks / Trade-offs
- [The admin knows the temporary password] → It is single-use in practice: the user must change it at first sign-in before any other call works. That is the same exposure as an emailed reset, minus the mailbox.
- [Existing sessions of the user survive the reset] → Same as the emailed reset today. Recorded as a follow-up with the existing "refreshed token stays valid" item.
- [Clipboard access needs HTTPS] → Production is HTTPS. If the copy fails, the password stays visible and selectable.
Migration Plan
No data change. Deploy services-system, mobile-api and the portal; the core-libs change ships inside each service jar. Rollback is the previous images.