Skip to content

Commit 190c710

Browse files
voidmainwied03
andauthored
FIPS (#168)
* IJ * Working --------- Co-authored-by: Brady Wied <brady.wied@fusionauth.io>
1 parent b45722c commit 190c710

3 files changed

Lines changed: 67 additions & 4 deletions

File tree

fusionauth-java-client.iml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
<module type="JAVA_MODULE" version="4">
33
<component name="FacetManager">
44
<facet type="Python" name="Python">
5-
<configuration sdkName="" />
5+
<configuration sdkName="Python 3.12" />
66
</facet>
77
</component>
88
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
99
<output url="file://$MODULE_DIR$/build/classes/main" />
1010
<output-test url="file://$MODULE_DIR$/build/classes/test" />
1111
<exclude-output />
12+
<content url="file://$MODULE_DIR$/../fusionauth-ij/queries" />
1213
<content url="file://$MODULE_DIR$">
1314
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
1415
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
@@ -139,6 +140,6 @@
139140
</SOURCES>
140141
</library>
141142
</orderEntry>
143+
<orderEntry type="library" name="Python 3.12 interpreter library" level="application" />
142144
</component>
143-
</module>
144-
145+
</module>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2025-2025, FusionAuth, All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing,
11+
* software distributed under the License is distributed on an
12+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
* either express or implied. See the License for the specific
14+
* language governing permissions and limitations under the License.
15+
*/
16+
package io.fusionauth.domain;
17+
18+
/**
19+
* Determines if FusionAuth is in FIPS mode based on the system property <code>fusionauth.fips.enabled</code>. This can only be enabled once and
20+
* should be enabled when the VM starts or as close to that point as possible.
21+
* <p>
22+
* Once this has been enabled, it cannot be disabled.
23+
* <p>
24+
* This also provides some helpers for FIPS things such as password length requirements.
25+
*
26+
* @author Brian Pontarelli & Daniel DeGroff
27+
*/
28+
public class FIPS {
29+
public static final int FIPS_MIN_PASSWORD_LENGTH = 14;
30+
31+
public static final int STANDARD_MIN_PASSWORD_LENGTH = 8;
32+
33+
private static volatile Boolean Enabled;
34+
35+
/**
36+
* Lazily determines if the System configuration is set to enable FIPS mode. This is done on the first call to this method. Subsequent calls return
37+
* the cached value, regardless of the System properties changing.
38+
*
39+
* @return Whether or not FIPS is enabled.
40+
*/
41+
public static boolean isEnabled() {
42+
if (Enabled != null) {
43+
return Enabled;
44+
}
45+
46+
Enabled = Boolean.getBoolean("fusionauth.fips.enabled");
47+
return Boolean.TRUE.equals(Enabled);
48+
}
49+
50+
/**
51+
* Returns the minimum password length requirement, which depends on whether FusionAuth is operating in FIPS mode.
52+
* If FIPS mode is enabled, the minimum password length will be {@code FIPS_MIN_PASSWORD_LENGTH}.
53+
* Otherwise, the minimum password length will be {@code STANDARD_MIN_PASSWORD_LENGTH}.
54+
*
55+
* @return The minimum password length, either {@code FIPS_MIN_PASSWORD_LENGTH} when FIPS mode is enabled or {@code STANDARD_MIN_PASSWORD_LENGTH}
56+
* when it is not.
57+
*/
58+
public static int minimumPasswordLength() {
59+
return isEnabled() ? FIPS_MIN_PASSWORD_LENGTH : STANDARD_MIN_PASSWORD_LENGTH;
60+
}
61+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class PasswordValidationRules implements Buildable<PasswordValidationRule
2828

2929
public int maxLength = 256;
3030

31-
public int minLength = 8;
31+
public int minLength;
3232

3333
public RememberPreviousPasswords rememberPreviousPasswords = new RememberPreviousPasswords();
3434

@@ -45,6 +45,7 @@ public class PasswordValidationRules implements Buildable<PasswordValidationRule
4545

4646
@JacksonConstructor
4747
public PasswordValidationRules() {
48+
this.minLength = FIPS.minimumPasswordLength();
4849
}
4950

5051
public PasswordValidationRules(PasswordValidationRules other) {

0 commit comments

Comments
 (0)