Class BlacklistPasswordPolicyProviderFactory
- java.lang.Object
- 
- org.keycloak.policy.BlacklistPasswordPolicyProviderFactory
 
- 
- All Implemented Interfaces:
- PasswordPolicyProviderFactory,- ProviderFactory<PasswordPolicyProvider>
 
 public class BlacklistPasswordPolicyProviderFactory extends Object implements PasswordPolicyProviderFactory CreatesBlacklistPasswordPolicyProviderinstances.Password blacklists are simple text files where every line is a blacklisted password delimited by a newline character \n.Blacklists can be configured via the Authentication: Password Policy section in the admin-console. A blacklist-file is referred to by its name in the policy configuration. Blacklist locationUsers can provide custom blacklists by adding a blacklist password file to the configured blacklist 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/blacklistsFolderNote that the preferred way for configuration is to copy the password file to the $KC_HOME/data/password-blacklists/folderA password blacklist with the filename 10_million_passwords.txtthat is located beneath$KC_HOME/data/keycloak/blacklists/can be referred to as10_million_passwords.txtin the Authentication: Password Policy configuration.False positivesThe current implementation uses a probabilistic data-structure called BloomFilterwhich allows for fast and memory efficient containment checks, e.g. whether a given password is contained in a blacklist, with the possibility for false positives. By default a false positive probabilityDEFAULT_FALSE_POSITIVE_PROBABILITYis 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 SummaryNested Classes Modifier and Type Class Description static classBlacklistPasswordPolicyProviderFactory.FileBasedPasswordBlacklistABlacklistPasswordPolicyProviderFactory.FileBasedPasswordBlacklistuses password-blacklist files as to construct aBlacklistPasswordPolicyProviderFactory.PasswordBlacklist.static interfaceBlacklistPasswordPolicyProviderFactory.PasswordBlacklistABlacklistPasswordPolicyProviderFactory.PasswordBlacklistdescribes a list of too easy to guess or potentially leaked passwords that users should not be able to use.
 - 
Field SummaryFields Modifier and Type Field Description static StringBLACKLISTS_FALSE_POSITIVE_PROBABILITY_PROPERTYstatic StringBLACKLISTS_PATH_PROPERTYstatic doubleDEFAULT_FALSE_POSITIVE_PROBABILITYstatic StringIDstatic StringJBOSS_SERVER_DATA_DIRstatic StringPASSWORD_BLACKLISTS_FOLDERstatic StringSYSTEM_PROPERTY
 - 
Constructor SummaryConstructors Constructor Description BlacklistPasswordPolicyProviderFactory()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()This is called when the server shuts down.PasswordPolicyProvidercreate(KeycloakSession session)StringgetConfigType()StringgetDefaultBlacklistsBasePath()Method to obtain the default location for the list folder.StringgetDefaultConfigValue()StringgetDisplayName()protected doublegetFalsePositiveProbability()StringgetId()voidinit(Config.Scope config)Only called once when the factory is first created.booleanisMultiplSupported()voidpostInit(KeycloakSessionFactory factory)Called after all provider factories have been initializedBlacklistPasswordPolicyProviderFactory.PasswordBlacklistresolvePasswordBlacklist(String blacklistName)Resolves and potentially registers aBlacklistPasswordPolicyProviderFactory.PasswordBlacklistfor the givenblacklistName.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.keycloak.provider.ProviderFactorygetConfigMetadata, order
 
- 
 
- 
- 
- 
Field Detail- 
IDpublic static final String ID - See Also:
- Constant Field Values
 
 - 
SYSTEM_PROPERTYpublic static final String SYSTEM_PROPERTY - See Also:
- Constant Field Values
 
 - 
BLACKLISTS_PATH_PROPERTYpublic static final String BLACKLISTS_PATH_PROPERTY - See Also:
- Constant Field Values
 
 - 
BLACKLISTS_FALSE_POSITIVE_PROBABILITY_PROPERTYpublic static final String BLACKLISTS_FALSE_POSITIVE_PROBABILITY_PROPERTY - See Also:
- Constant Field Values
 
 - 
DEFAULT_FALSE_POSITIVE_PROBABILITYpublic static final double DEFAULT_FALSE_POSITIVE_PROBABILITY - See Also:
- Constant Field Values
 
 - 
JBOSS_SERVER_DATA_DIRpublic static final String JBOSS_SERVER_DATA_DIR - See Also:
- Constant Field Values
 
 - 
PASSWORD_BLACKLISTS_FOLDERpublic static final String PASSWORD_BLACKLISTS_FOLDER 
 
- 
 - 
Method Detail- 
createpublic PasswordPolicyProvider create(KeycloakSession session) - Specified by:
- createin interface- ProviderFactory<PasswordPolicyProvider>
 
 - 
initpublic void init(Config.Scope config) Description copied from interface:ProviderFactoryOnly called once when the factory is first created. This config is pulled from keycloak_server.json- Specified by:
- initin interface- ProviderFactory<PasswordPolicyProvider>
 
 - 
postInitpublic void postInit(KeycloakSessionFactory factory) Description copied from interface:ProviderFactoryCalled after all provider factories have been initialized- Specified by:
- postInitin interface- ProviderFactory<PasswordPolicyProvider>
 
 - 
closepublic void close() Description copied from interface:ProviderFactoryThis is called when the server shuts down.- Specified by:
- closein interface- ProviderFactory<PasswordPolicyProvider>
 
 - 
getDisplayNamepublic String getDisplayName() - Specified by:
- getDisplayNamein interface- PasswordPolicyProviderFactory
 
 - 
getConfigTypepublic String getConfigType() - Specified by:
- getConfigTypein interface- PasswordPolicyProviderFactory
 
 - 
getDefaultConfigValuepublic String getDefaultConfigValue() - Specified by:
- getDefaultConfigValuein interface- PasswordPolicyProviderFactory
 
 - 
isMultiplSupportedpublic boolean isMultiplSupported() - Specified by:
- isMultiplSupportedin interface- PasswordPolicyProviderFactory
 
 - 
getIdpublic String getId() - Specified by:
- getIdin interface- ProviderFactory<PasswordPolicyProvider>
 
 - 
getDefaultBlacklistsBasePathpublic String getDefaultBlacklistsBasePath() 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.
 
 - 
resolvePasswordBlacklistpublic BlacklistPasswordPolicyProviderFactory.PasswordBlacklist resolvePasswordBlacklist(String blacklistName) Resolves and potentially registers aBlacklistPasswordPolicyProviderFactory.PasswordBlacklistfor the givenblacklistName.- Parameters:
- blacklistName-
- Returns:
 
 - 
getFalsePositiveProbabilityprotected double getFalsePositiveProbability() 
 
- 
 
-