mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-07-20 23:57:11 -04:00
[PR #169] [CLOSED] fix: enforce strong password policy on admin user creation #209
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/vxcontrol/pentagi/pull/169
Author: @mason5052
Created: 3/2/2026
Status: ❌ Closed
Base:
master← Head:fix/user-password-validation📝 Commits (1)
54da403fix: enforce strong password policy on admin user creation📊 Changes
1 file changed (+1 additions, -1 deletions)
View changed files
📝
backend/pkg/server/models/users.go(+1 -1)📄 Description
Description of the Change
Problem
The password validation policy is inconsistent across user models:
UserPasswordmax=100,requiredPasswordstpass,max=100,requiredLoginmin=4,max=100,requiredThe
UserPasswordmodel accepts any password up to 100 characters with no minimum length or complexity requirement. An admin can create a user with a trivially weak password like"a"or"1234".The
Passwordmodel correctly uses thestpass(strong password) custom validator, which requires either:[!@#$&*]Solution
Add the
stpassvalidator toUserPassword.Passwordto enforce the same strength policy on admin user creation as on self-service password changes.The
Loginmodel is intentionally left withmin=4since it only validates login attempt input, not password creation.Type of Change
Areas Affected
Testing and Verification
Test Configuration
Test Steps
init.goto confirmstpassvalidator is registered and usesstrongPasswordValidatorString()strongPasswordValidatorString()logic: accepts 16+ chars OR 8+ with mixed case/digits/specialsPasswordmodel already usesstpasssuccessfullyUserPasswordis used in admin user creation path (services/users.go)Test Results
stpassvalidator is already battle-tested via thePasswordmodelSecurity Considerations
This fix closes a password policy gap. Without it, an admin (or an attacker who compromises an admin account) can create users with trivially guessable passwords, bypassing the strong password policy enforced on self-service changes.
Performance Impact
None. The
stpassvalidator uses pre-compiled regexes and runs in microseconds.Deployment Notes
Breaking change for weak admin-created passwords only. After this fix, admin API calls to create users with passwords shorter than 8 characters (or 16 without complexity) will fail validation. Existing users are not affected unless their password is reset via the admin API.
Checklist
Code Quality
go fmtandgo vet(for Go code)Security
Compatibility
Documentation
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.