Skip to content

Commit 10bad46

Browse files
authored
ENG-990: Disallow password which is the same as user's login (#1225)
Added a field `PasswordValidationRules.disallowUserLoginId`, configurable per tenant. If enabled, passwords will be rejected if they contain the user's email, username, or phone number.
1 parent a5c8b05 commit 10bad46

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/main/java/io/fusionauth/domain/PasswordValidationRules.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, FusionAuth, All Rights Reserved
2+
* Copyright (c) 2019-2026, FusionAuth, All Rights Reserved
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,9 @@
2626
public class PasswordValidationRules implements Buildable<PasswordValidationRules> {
2727
public PasswordBreachDetection breachDetection = new PasswordBreachDetection();
2828

29+
// Reject passwords that include the user's email, username, or phone number
30+
public boolean disallowUserLoginId;
31+
2932
public int maxLength = 256;
3033

3134
public int minLength;
@@ -49,6 +52,7 @@ public PasswordValidationRules() {
4952
}
5053

5154
public PasswordValidationRules(PasswordValidationRules other) {
55+
this.disallowUserLoginId = other.disallowUserLoginId;
5256
this.breachDetection = new PasswordBreachDetection(other.breachDetection);
5357
this.maxLength = other.maxLength;
5458
this.minLength = other.minLength;
@@ -68,7 +72,8 @@ public boolean equals(Object o) {
6872
return false;
6973
}
7074
PasswordValidationRules that = (PasswordValidationRules) o;
71-
return maxLength == that.maxLength &&
75+
return disallowUserLoginId == that.disallowUserLoginId &&
76+
maxLength == that.maxLength &&
7277
minLength == that.minLength &&
7378
requireMixedCase == that.requireMixedCase &&
7479
requireNonAlpha == that.requireNonAlpha &&
@@ -79,7 +84,7 @@ public boolean equals(Object o) {
7984

8085
@Override
8186
public int hashCode() {
82-
return Objects.hash(breachDetection, maxLength, minLength, rememberPreviousPasswords, requireMixedCase, requireNonAlpha, requireNumber, validateOnLogin);
87+
return Objects.hash(disallowUserLoginId, breachDetection, maxLength, minLength, rememberPreviousPasswords, requireMixedCase, requireNonAlpha, requireNumber, validateOnLogin);
8388
}
8489

8590
@Override

0 commit comments

Comments
 (0)