Skip to content

Commit f9f542b

Browse files
Added validation of FIPS password length (jenkinsci#8694)
Co-authored-by: Daniel Beck <[email protected]>
1 parent aedae5b commit f9f542b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
* @author Kohsuke Kawaguchi
115115
*/
116116
public class HudsonPrivateSecurityRealm extends AbstractPasswordBasedSecurityRealm implements ModelObject, AccessControlled {
117+
private static final int FIPS_PASSWORD_LENGTH = 14;
117118
private static /* not final */ String ID_REGEX = System.getProperty(HudsonPrivateSecurityRealm.class.getName() + ".ID_REGEX");
118119

119120
/**
@@ -452,6 +453,11 @@ private SignupInfo validateAccountCreationForm(StaplerRequest req, boolean valid
452453
si.errors.put("password1", Messages.HudsonPrivateSecurityRealm_CreateAccount_PasswordRequired());
453454
}
454455

456+
if (FIPS140.useCompliantAlgorithms()) {
457+
if (si.password1.length() < FIPS_PASSWORD_LENGTH) {
458+
si.errors.put("password1", Messages.HudsonPrivateSecurityRealm_CreateAccount_FIPS_PasswordLengthInvalid());
459+
}
460+
}
455461
if (si.fullname == null || si.fullname.isEmpty()) {
456462
si.fullname = si.username;
457463
}

core/src/main/resources/hudson/security/Messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ HudsonPrivateSecurityRealm.ManageUserLinks.Description=Create/delete/modify user
3636

3737
HudsonPrivateSecurityRealm.CreateAccount.TextNotMatchWordInImage=Text didn''t match the word shown in the image
3838
HudsonPrivateSecurityRealm.CreateAccount.PasswordNotMatch=Password didn''t match
39+
HudsonPrivateSecurityRealm.CreateAccount.FIPS.PasswordLengthInvalid=Password must be at least 14 characters long
3940
HudsonPrivateSecurityRealm.CreateAccount.PasswordRequired=Password is required
4041
HudsonPrivateSecurityRealm.CreateAccount.UserNameRequired=User name is required
4142
HudsonPrivateSecurityRealm.CreateAccount.UserNameInvalidCharacters=User name must only contain alphanumeric characters, underscore and dash

0 commit comments

Comments
 (0)