Password Reset
Production - POST /api/v1/users/me/password, POST /api/v1/users/{userId}/reset-password
The IAM service supports two password change flows: self-service password change for authenticated users and admin-initiated password reset for locked or forgotten accounts.
6.2.10Self-Service Password Change
Authenticated users can change their own password by providing their current password and a new one.
Request
curl -X POST http://localhost:8081/api/v1/users/me/password \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access-token>" \
-H "X-Tenant-ID: 00000000-0000-0000-0000-000000000001" \
-d '{
"currentPassword": "OldP@ssw0rd!",
"newPassword": "NewSecureP@ss123!"
}'Request Schema
| Field | Type | Required | Description |
|---|---|---|---|
currentPassword | String | Yes | Current password for verification |
newPassword | String | Yes | New password (must meet policy requirements) |
Response (204 No Content)
Empty response body on success.
Implementation
The PasswordService.changePassword() method:
- Verifies the current password against the stored hash
- Validates the new password against the tenant's password policy (minimum length, complexity, history)
- Checks password history to prevent reuse of recent passwords
- Hashes the new password with BCrypt and updates the user record
- Records the password change in
PasswordHistoryfor future reuse checks - Updates
passwordChangedAttimestamp on the user entity
6.2.11Admin Password Reset
Administrators can reset any user's password within their tenant. This generates a temporary password that must be changed on first login.
Request
curl -X POST http://localhost:8081/api/v1/users/42/reset-password \
-H "Authorization: Bearer <admin-token>" \
-H "X-Tenant-ID: 550e8400-e29b-41d4-a716-446655440000"Response (200 OK)
{
"temporaryPassword": "Tmp#xK9mQ2pL"
}Security Considerations
- This endpoint requires
ADMINorPLATFORM_ADMINrole (@PreAuthorize("hasAnyRole('ADMIN', 'PLATFORM_ADMIN')")) - The temporary password is returned only once in the response -- it is not stored in plain text
- The user's
passwordChangedAtis cleared to indicate a forced password change is needed - An audit log entry is created for compliance tracking
Password Policy Enforcement
The PasswordPolicyService validates passwords against configurable per-tenant rules:
| Policy | Default | Description |
|---|---|---|
| Minimum length | 8 | Minimum number of characters |
| Maximum length | 128 | Maximum number of characters |
| Require uppercase | Yes | At least one uppercase letter |
| Require lowercase | Yes | At least one lowercase letter |
| Require digit | Yes | At least one numeric digit |
| Require special | Yes | At least one special character |
| Password history | 5 | Number of previous passwords that cannot be reused |
| Max age (days) | 90 | Password expiration period |
Error Codes
| Code | HTTP Status | Description |
|---|---|---|
AUTHENTICATION_FAILED | 401 | Current password is incorrect |
BUSINESS_RULE_VIOLATION | 400 | New password does not meet policy requirements |
PASSWORD_REUSE | 400 | Password was used recently |
RESOURCE_NOT_FOUND | 404 | User not found |
ACCESS_DENIED | 403 | Insufficient permissions for admin reset |