Skip to content

Commit

Permalink
Merge pull request #2823 from zlamalp/einfra
Browse files Browse the repository at this point in the history
CORE: Simplified and fixed einfra password check
  • Loading branch information
zlamalp committed Jul 29, 2020
1 parent c34ccf6 commit 427bb23
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ public void checkPasswordStrength(PerunSession sess, String login, String passwo
throw new PasswordStrengthException("Password for " + actualLoginNamespace + ":" + login + " is too short. At least 10 characters is required.");
}

String backwardPassword = StringUtils.reverse(password);

if (password.equalsIgnoreCase(login) ||
backwardPassword.equalsIgnoreCase(login) ||
password.toLowerCase().contains(login.toLowerCase()) ||
backwardPassword.toLowerCase().contains(login.toLowerCase())) {
log.warn("Password for {}:{} must not match/contain login or backwards login.", actualLoginNamespace, login);
throw new PasswordStrengthException("Password for " + actualLoginNamespace + ":" + login + " must not match/contain login or backwards login.");
// if login is at least 3 chars, test if its not contained in password
if (login.length() > 2) {
String backwardsLogin = StringUtils.reverse(login);
if (password.toLowerCase().contains(login.toLowerCase()) ||
password.toLowerCase().contains(backwardsLogin.toLowerCase())) {
log.warn("Password for {}:{} must not match/contain login or backwards login.", actualLoginNamespace, login);
throw new PasswordStrengthException("Password for " + actualLoginNamespace + ":" + login + " must not match/contain login or backwards login.");
}
}

// TODO - fetch user and get names to make sure they are not part of password
Expand Down

0 comments on commit 427bb23

Please sign in to comment.