Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: password validation regexp in settings #19574

Merged
merged 8 commits into from
Jan 20, 2025
Merged

feat: password validation regexp in settings #19574

merged 8 commits into from
Jan 20, 2025

Conversation

netroms
Copy link
Contributor

@netroms netroms commented Dec 30, 2024

Summary

This introduces a new system setting called passwordValidationPattern, this is a Regexp version of the internal password rule set, to be used in clients, most important the standard web UI.
Since the password validation is configurable in the back-end, (currently only max and min password length), the rule aka. Regexp needs to be provided dynamically from the back-end.
This new property along with the min and max length properties are also exposed in the LoginConfigController, for easy access in non logged in environments, like the signup page.

Fix

This PR also fixes an issue with the current back-end password rules not checking for a lower-case character present, this is enforced in the UI, but not in the back-end. To align this, a new password rule was added, called LowerCasePatternValidationRule.java. Since this rule was expected and always enforced in the UI, I see this as safe to add.

Automatic tests

SystemSettingsTest.java
UserTest.java
LoginConfigControllerTest.java
UserAccountControllerTest.java

Manual test

  1. Call API endpoint /systemSettings
  2. Observe there is a passwordValidationPattern property present and that the value is: ^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[\W_])[A-Za-z\d\W_]{8,72}$
  3. Call API endpoint /loginConfig
  4. Observe the same property is present along with minPasswordLength and maxPasswordLength

JIRA: DHIS2-18574

Signed-off-by: Morten Svanaes <msvanaes@dhis2.org>
Signed-off-by: Morten Svanaes <msvanaes@dhis2.org>
Signed-off-by: Morten Svanaes <msvanaes@dhis2.org>
Signed-off-by: Morten Svanaes <msvanaes@dhis2.org>
Signed-off-by: Morten Svanaes <msvanaes@dhis2.org>
Copy link

@netroms netroms merged commit a7da078 into master Jan 20, 2025
17 checks passed
@netroms netroms deleted the DHIS2-18574 branch January 20, 2025 13:44
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