Skip to content

BYNT-1387: enforce password policies in backend + chore: configure gitleaks to ignore tests#129

Merged
tarekio merged 15 commits intomainfrom
bynt-1387-enforce-password-policies
Jul 22, 2025
Merged

BYNT-1387: enforce password policies in backend + chore: configure gitleaks to ignore tests#129
tarekio merged 15 commits intomainfrom
bynt-1387-enforce-password-policies

Conversation

@cango91
Copy link
Contributor

@cango91 cango91 commented Jul 7, 2025

Jira Issue

  1. BYNT-1387

Description

  • Add password validation using zxcvbn in UserValidationModel and UserPasswordCheckValidationModel
  • Implement minimum password length enforcement (8 characters)
  • Add password complexity validation to CLI commands (install and create user)
  • Create validate_password_zxcvbn utility function
  • Simplify password check API to rely on validation models
  • Ensure password policies are enforced in admin dashboard and user management

Checklist

  • Tests added/updated
  • Documentation updated (if needed)
  • New strings prepared for translations

API Changes (if applicable)

  • Permissions checked
  • Endpoint tests added

Additional Notes

[Any other relevant information]

cango91 added 5 commits July 7, 2025 15:39
- Add password validation using zxcvbn in UserValidationModel and UserPasswordCheckValidationModel
- Implement minimum password length enforcement (8 characters)
- Add password complexity validation to CLI commands (install and create user)
- Create validate_password_zxcvbn utility function
- Simplify password check API to rely on validation models
- Ensure password policies are enforced in admin dashboard and user management
@cango91 cango91 requested a review from tarekio July 7, 2025 22:02
Copy link
Collaborator

@level09 level09 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the comments, we can update the password reset cli command to also use our centralized validation :

try:
    password = validate_password_policy(password)
except ValueError as e:
    click.echo(str(e))
    logger.error(str(e))
    return

if not (p := p.strip()):
raise ValueError("Password cannot be empty!")
# validate length
min_length = getattr(cfg, "SECURITY_PASSWORD_MIN_LENGTH", 8)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The config variable name is incorrect, causing it to always use the default value of 8
  • we don't need a fallback value, the configuration variable should always be set and it has the fallback value of 10

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great catch! fixed in c9d2bd5

@cango91 cango91 self-assigned this Jul 8, 2025
@tarekio tarekio requested a review from level09 July 9, 2025 13:11
Copy link
Collaborator

@level09 level09 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good to go 👍

cango91 and others added 3 commits July 18, 2025 09:23
## Jira Issue
1. [BYNT-1386](https://syriajustice.atlassian.net/browse/BYNT-1386)

## Description
Add password validations checks to change_password.html and users.html

## Checklist
- [ ] Tests added/updated
- [ ] Documentation updated (if needed)
- [ ] New strings prepared for translations

## API Changes (if applicable)
- [ ] Permissions checked
- [ ] Endpoint tests added

## Additional Notes
[Any other relevant information]


[BYNT-1386]:
https://syriajustice.atlassian.net/browse/BYNT-1386?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
@tarekio tarekio merged commit 60168f3 into main Jul 22, 2025
6 of 7 checks passed
@tarekio tarekio deleted the bynt-1387-enforce-password-policies branch July 22, 2025 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants