MATIH Platform is in active MVP development. Documentation reflects current implementation status.
6. Identity & Access Management
User Management
Password Policies

Password Policies

Production - PasswordPolicyService, PasswordExpirationService

Password policies enforce security requirements for user passwords. Each tenant can configure its own policy defining minimum complexity, maximum age, and history constraints.


6.4.12Policy Configuration

The PasswordPolicy entity stores per-tenant password rules:

RuleDefaultDescription
minLength8Minimum password length
maxLength128Maximum password length
requireUppercasetrueMust contain uppercase letter
requireLowercasetrueMust contain lowercase letter
requireDigittrueMust contain numeric digit
requireSpecialtrueMust contain special character
historyCount5Previous passwords that cannot be reused
maxAgeDays90Days before password expiration
minAgeDays1Minimum days between changes

6.4.13Password History

The PasswordHistory table stores hashed versions of previous passwords. When a user changes their password, the service checks the history:

// Check against last N passwords
List<PasswordHistory> history = passwordHistoryRepository
    .findTopNByUserIdOrderByCreatedAtDesc(userId, policy.getHistoryCount());
 
for (PasswordHistory ph : history) {
    if (passwordEncoder.matches(newPassword, ph.getPasswordHash())) {
        throw new BusinessException("Password was used recently");
    }
}

6.4.14Password Expiration

The PasswordExpirationService checks whether a user's password has exceeded the maximum age:

  • user.passwordChangedAt tracks when the password was last changed
  • If now - passwordChangedAt > maxAgeDays, the user is prompted to change their password
  • The PasswordExpirationService can be invoked during login to enforce mandatory password rotation

Related Services

ServiceResponsibility
PasswordServicePassword change and reset operations
PasswordPolicyServicePolicy CRUD and validation
PasswordExpirationServiceExpiration checking and enforcement