Class DenylistPasswordPolicyProviderFactory
- All Implemented Interfaces:
PasswordPolicyProviderFactory,org.keycloak.provider.ProviderFactory<org.keycloak.policy.PasswordPolicyProvider>
DenylistPasswordPolicyProvider instances.
Password denylists are simple text files where every line is a denylisted password delimited by a newline character \n.
Denylists can be configured via the Authentication: Password Policy section in the admin-console. A denylist-file is referred to by its name in the policy configuration.
Denylist location
Users can provide custom denylists by adding a denylist password file to the configured denylist folder.
The location of the password-blacklists folder is derived as follows
- the value of the System property
keycloak.password.blacklists.pathif configured - fails if folder is missing - the value of the SPI config property:
blacklistsPathwhen explicitly configured - fails if folder is missing - otherwise
$KC_HOME/data/password-blacklists/if nothing else is configured
--spi-password-policy-password-blacklist-blacklists-path=/path/to/denylistsFolder
Note that the preferred way for configuration is to copy the password file to the $KC_HOME/data/password-blacklists/ folder
A password denylist with the filename 10_million_passwords.txt
that is located beneath $KC_HOME/data/keycloak/blacklists/ can be referred to as 10_million_passwords.txt in the Authentication: Password Policy configuration.
False positives
The current implementation uses a probabilistic data-structure called BloomFilter which allows for fast and memory efficient containment checks, e.g. whether a given password is contained in a denylist,
with the possibility for false positives. By default a false positive probability DEFAULT_FALSE_POSITIVE_PROBABILITY is used.
To change the false positive probability via CLI configuration use --spi-password-policy-password-blacklist-false-positive-probability=0.00001
- Author:
- Thomas Darimont
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classADenylistPasswordPolicyProviderFactory.FileBasedPasswordDenylistuses password-denylist files to construct aDenylistPasswordPolicyProviderFactory.PasswordDenylist.static interfaceADenylistPasswordPolicyProviderFactory.PasswordDenylistdescribes a list of too easy to guess or potentially leaked passwords that users should not be able to use. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidbuildBloomFile(Path inputFile, Path outputFile, double fpp) Builds a pre-computed Bloom filter (.bloom) file from a plaintext password denylist file.voidclose()org.keycloak.policy.PasswordPolicyProvidercreate(org.keycloak.models.KeycloakSession session) protected intList<org.keycloak.provider.ProviderConfigProperty>Method to obtain the default location for the list folder.protected doublegetId()voidinit(org.keycloak.Config.Scope config) booleanvoidpostInit(org.keycloak.models.KeycloakSessionFactory factory) resolvePasswordDenylist(String denylistName) Resolves and potentially registers aDenylistPasswordPolicyProviderFactory.PasswordDenylistfor the givendenylistName.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.provider.ProviderFactory
dependsOn, order
-
Field Details
-
ID
- See Also:
-
SYSTEM_PROPERTY
- See Also:
-
BLACKLISTS_PATH_PROPERTY
- See Also:
-
BLACKLISTS_FALSE_POSITIVE_PROBABILITY_PROPERTY
- See Also:
-
CHECK_INTERVAL_SECONDS_PROPERTY
- See Also:
-
DEFAULT_FALSE_POSITIVE_PROBABILITY
public static final double DEFAULT_FALSE_POSITIVE_PROBABILITY- See Also:
-
DEFAULT_CHECK_INTERVAL_SECONDS
public static final int DEFAULT_CHECK_INTERVAL_SECONDS- See Also:
-
JBOSS_SERVER_DATA_DIR
- See Also:
-
PASSWORD_BLACKLISTS_FOLDER
-
-
Constructor Details
-
DenylistPasswordPolicyProviderFactory
public DenylistPasswordPolicyProviderFactory()
-
-
Method Details
-
create
public org.keycloak.policy.PasswordPolicyProvider create(org.keycloak.models.KeycloakSession session) - Specified by:
createin interfaceorg.keycloak.provider.ProviderFactory<org.keycloak.policy.PasswordPolicyProvider>
-
init
public void init(org.keycloak.Config.Scope config) - Specified by:
initin interfaceorg.keycloak.provider.ProviderFactory<org.keycloak.policy.PasswordPolicyProvider>
-
postInit
public void postInit(org.keycloak.models.KeycloakSessionFactory factory) - Specified by:
postInitin interfaceorg.keycloak.provider.ProviderFactory<org.keycloak.policy.PasswordPolicyProvider>
-
close
public void close()- Specified by:
closein interfaceorg.keycloak.provider.ProviderFactory<org.keycloak.policy.PasswordPolicyProvider>
-
getDisplayName
- Specified by:
getDisplayNamein interfacePasswordPolicyProviderFactory
-
getConfigType
- Specified by:
getConfigTypein interfacePasswordPolicyProviderFactory
-
getDefaultConfigValue
- Specified by:
getDefaultConfigValuein interfacePasswordPolicyProviderFactory
-
isMultiplSupported
public boolean isMultiplSupported()- Specified by:
isMultiplSupportedin interfacePasswordPolicyProviderFactory
-
getId
- Specified by:
getIdin interfaceorg.keycloak.provider.ProviderFactory<org.keycloak.policy.PasswordPolicyProvider>
-
getDefaultDenylistsBasePath
Method to obtain the default location for the list folder. The method will return the data directory of the Keycloak instance concatenated with /password-blacklists/.- Returns:
- The default path used by the provider to lookup the lists when no other configuration is in place.
-
resolvePasswordDenylist
public DenylistPasswordPolicyProviderFactory.PasswordDenylist resolvePasswordDenylist(String denylistName) Resolves and potentially registers aDenylistPasswordPolicyProviderFactory.PasswordDenylistfor the givendenylistName.- Parameters:
denylistName-- Returns:
-
getFalsePositiveProbability
protected double getFalsePositiveProbability() -
getCheckIntervalSeconds
protected int getCheckIntervalSeconds() -
getConfigMetadata
- Specified by:
getConfigMetadatain interfaceorg.keycloak.provider.ProviderFactory<org.keycloak.policy.PasswordPolicyProvider>
-
buildBloomFile
Builds a pre-computed Bloom filter (.bloom) file from a plaintext password denylist file. Each line is treated as one password (lowercased before insertion).- Parameters:
inputFile- path to the plaintext password list (one password per line, UTF-8)outputFile- path for the generated .bloom filefpp- desired false-positive probability (e.g. 0.0001)- Throws:
IOException- if the input file cannot be read or the output file cannot be written
-