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

Updating password rules #2842

Merged
merged 9 commits into from
Mar 20, 2025
Merged

Updating password rules #2842

merged 9 commits into from
Mar 20, 2025

Conversation

muralibasani
Copy link
Contributor

Linked issue

Resolves: #xxxxx

What kind of change does this PR introduce?

  • Bug fix
  • New feature
  • Refactor
  • Docs update
  • CI update

What is the current behavior?

Describe the state of the application before this PR. Illustrations appreciated (videos, gifs, screenshots).

What is the new behavior?

Describe the state of the application after this PR. Illustrations appreciated (videos, gifs, screenshots).

Other information

Additional changes, explanations of the approach taken, unresolved issues, necessary follow ups, etc.

Requirements (all must be checked before review)

  • The pull request title follows our guidelines
  • Tests for the changes have been added (if relevant)
  • The latest changes from the main branch have been pulled
  • pnpm lint has been run successfully

@muralibasani muralibasani marked this pull request as ready for review March 17, 2025 13:55
@muralibasani muralibasani requested a review from nosahama March 17, 2025 14:01
nosahama
nosahama previously approved these changes Mar 18, 2025
Signed-off-by: Muralidhar Basani <[email protected]>
Copy link
Contributor

@aindriu-aiven aindriu-aiven left a comment

Choose a reason for hiding this comment

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

A few comments for consideration.

@@ -8,7 +8,7 @@ services:
SPRING_DATASOURCE_URL: "jdbc:h2:file:/klaw/klawprodb;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1;MODE=MySQL;CASE_INSENSITIVE_IDENTIFIERS=TRUE;"
KLAW_UIAPI_SERVERS: "http://klaw-core:9097"
KLAW_CLUSTERAPI_URL: "http://klaw-cluster-api:9343"
KLAW_SUPERADMIN_DEFAULT_PASSWORD: 'welcometoklaw'
KLAW_SUPERADMIN_DEFAULT_PASSWORD: 'WelcomeToKlaw321@'
Copy link
Contributor

Choose a reason for hiding this comment

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

We will need to make an update to klaw docs to let folks know we have updated this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just so we can merge one and then immediately merge the other

violations.forEach(
vio ->
assertThat(vio.getMessage())
.contains("Password must be at least 8 characters long and include at least"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should just check this and line 909 against the constant PASSWORD_REGEX_VALIDATION_STR

@@ -889,6 +897,31 @@ public void changePwd() throws KlawException {
changePwdEncodedParams(updatePwdUserDetails, changePwdRequestModel);
}

@Test
Copy link
Contributor

Choose a reason for hiding this comment

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

You could also @ParamterizedTest this and add a CSVSource with "password,violationsCount" and fire in a number of passwords, it should simplify the test and show xactly what passwords are and are not allowed.

violations.forEach(
vio ->
assertThat(vio.getMessage())
.contains("Password must be at least 8 characters long and include at least"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can check against the constant here as well.

@NotNull
@Pattern(regexp = PASSWORD_REGEX, message = PASSWORD_REGEX_VALIDATION_STR)
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be worth splitting the @pattern into 3 or 4 things to give concise feedback about the issue with the password wdyt?

e.g.
@pattern(regex = "(?=.[a-z])" message = "must contain at least 1 lower case letter")
@pattern(regex = "(?=.
[A-Z])" message = "must contain at least 1 upper case letter")
@pattern(regex = "(?=.[0-9])" message = "must contain at least 1 number")
@pattern(regex = "(?=.
["!@#$%&*()'+,-./:;<=>?[]^_`{|}"])" message = "must contain at least 1 special character")
@SiZe(min = 8)

Note have not tested above regex

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have the same pattern check in front end.
This pattern is invoked only when someone is invoking BE apis manually, and we have not enabled them yet.

@@ -336,7 +342,7 @@ app.controller("manageUsersCtrl", function($scope, $http, $location, $window) {

if(!$scope.addNewUser.pwd)
{
$scope.alertnote = "Please enter a password.";
$scope.alertnote = "Please enter a suggested password.";
Copy link
Contributor

Choose a reason for hiding this comment

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

i dont think you need to add suggested here, as they should be entering their password?

@@ -389,7 +389,7 @@ app.controller("registerUsersCtrl", function($scope, $http, $location, $window)

if(!$scope.registerUser.pwd)
{
$scope.alertnote = "Please enter a password.";
$scope.alertnote = "Please enter a suggested password.";
Copy link
Contributor

Choose a reason for hiding this comment

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

same I dont think you need to change it to suggested here

Signed-off-by: Muralidhar Basani <[email protected]>
nosahama
nosahama previously approved these changes Mar 19, 2025
@muralibasani
Copy link
Contributor Author

@aindriu-aiven can you take a look again ?

Copy link
Contributor

@aindriu-aiven aindriu-aiven left a comment

Choose a reason for hiding this comment

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

Tested changing password through old and new UI and tested creating a new user, having admin reset password as well.

The one area I fond that wasnt covered by the improved password policy was the password reset page.
Here any password can be added without validation.

UserTeamsControllerService and i think forgotPassword.js need to be updated

@aindriu-aiven
Copy link
Contributor

Tested changing password through old and new UI and tested creating a new user, having admin reset password as well.

The one area I fond that wasnt covered by the improved password policy was the password reset page. Here any password can be added without validation.

UserTeamsControllerService and i think forgotPassword.js need to be updated

@muralibasani you can just make the change on the API to check it, the error should be propagated back to the UI.

@muralibasani
Copy link
Contributor Author

Tested changing password through old and new UI and tested creating a new user, having admin reset password as well.

The one area I fond that wasnt covered by the improved password policy was the password reset page. Here any password can be added without validation.

UserTeamsControllerService and i think forgotPassword.js need to be updated

Right, updated and added a test.

Copy link
Contributor

@aindriu-aiven aindriu-aiven left a comment

Choose a reason for hiding this comment

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

LGTM thank you

@muralibasani muralibasani merged commit ba9baaa into main Mar 20, 2025
30 checks passed
@muralibasani muralibasani deleted the pwd-policy branch March 20, 2025 11:33
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