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
\n. Blacklist files are discovered and registered at startup.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.
Users 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
${jboss.server.data.dir}/password-blacklists/if nothing else is configured - the folder is created automatically if not present
Note that the preferred way for configuration is to copy the password file to the
${jboss.server.data.dir}/password-blacklists/folderTo configure a password blacklist via the SPI configuration, run the following jboss-cli script:
/subsystem=keycloak-server/spi=password-policy:add() /subsystem=keycloak-server/spi=password-policy/provider=passwordBlacklist:add(enabled=true) /subsystem=keycloak-server/spi=password-policy/provider=passwordBlacklist:write-attribute(name=properties.blacklistsPath, value=/data/keycloak/blacklists/)A password blacklist with the filename
10_million_password_list_top_1000000-password-blacklist.txtthat is located beneath/data/keycloak/blacklists/can be referred to as10_million_password_list_top_1000000-password-blacklist.txtin the Authentication: Password Policy configuration.- Author:
- Thomas Darimont
-
-
Nested Class Summary
Nested 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 Summary
Fields Modifier and Type Field Description static StringBLACKLISTS_PATH_PROPERTYstatic StringIDstatic StringJBOSS_SERVER_DATA_DIRstatic StringPASSWORD_BLACKLISTS_FOLDERstatic StringSYSTEM_PROPERTY
-
Constructor Summary
Constructors Constructor Description BlacklistPasswordPolicyProviderFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()PasswordPolicyProvidercreate(KeycloakSession session)StringgetConfigType()StringgetDefaultConfigValue()StringgetDisplayName()StringgetId()voidinit(Config.Scope config)booleanisMultiplSupported()voidpostInit(KeycloakSessionFactory factory)BlacklistPasswordPolicyProviderFactory.PasswordBlacklistresolvePasswordBlacklist(String blacklistName)Resolves and potentially registers aBlacklistPasswordPolicyProviderFactory.PasswordBlacklistfor the givenblacklistName.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.keycloak.provider.ProviderFactory
order
-
-
-
-
Field Detail
-
ID
public static final String ID
- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY
public static final String SYSTEM_PROPERTY
- See Also:
- Constant Field Values
-
BLACKLISTS_PATH_PROPERTY
public static final String BLACKLISTS_PATH_PROPERTY
- See Also:
- Constant Field Values
-
JBOSS_SERVER_DATA_DIR
public static final String JBOSS_SERVER_DATA_DIR
- See Also:
- Constant Field Values
-
PASSWORD_BLACKLISTS_FOLDER
public static final String PASSWORD_BLACKLISTS_FOLDER
- See Also:
- Constant Field Values
-
-
Method Detail
-
create
public PasswordPolicyProvider create(KeycloakSession session)
- Specified by:
createin interfaceProviderFactory<PasswordPolicyProvider>
-
init
public void init(Config.Scope config)
- Specified by:
initin interfaceProviderFactory<PasswordPolicyProvider>
-
postInit
public void postInit(KeycloakSessionFactory factory)
- Specified by:
postInitin interfaceProviderFactory<PasswordPolicyProvider>
-
close
public void close()
- Specified by:
closein interfaceProviderFactory<PasswordPolicyProvider>
-
getDisplayName
public String getDisplayName()
- Specified by:
getDisplayNamein interfacePasswordPolicyProviderFactory
-
getConfigType
public String getConfigType()
- Specified by:
getConfigTypein interfacePasswordPolicyProviderFactory
-
getDefaultConfigValue
public String getDefaultConfigValue()
- Specified by:
getDefaultConfigValuein interfacePasswordPolicyProviderFactory
-
isMultiplSupported
public boolean isMultiplSupported()
- Specified by:
isMultiplSupportedin interfacePasswordPolicyProviderFactory
-
getId
public String getId()
- Specified by:
getIdin interfaceProviderFactory<PasswordPolicyProvider>
-
resolvePasswordBlacklist
public BlacklistPasswordPolicyProviderFactory.PasswordBlacklist resolvePasswordBlacklist(String blacklistName)
Resolves and potentially registers aBlacklistPasswordPolicyProviderFactory.PasswordBlacklistfor the givenblacklistName.- Parameters:
blacklistName-- Returns:
-
-