To check the strength of the password (Calculated entropy returned from the algorithm) and return it to the caller while creating an account/user or updating a user's password.
Try to enable an interface that can be implemented as a plugin and injected at necessary places for any type of password strength checker. This way we can make sure each component/plugin can have plugins to check
password strengths on their own way.
The following API responses will be changed to support this as of now.
The following response parameter is started returning from above commands
Add new Inerface "org.apache.cloudstack.security.password.PasswordChecker.java" to "server".
This interface will have the following declaration:
public Float checkPassword(String password);
This interface will have the following config keys which needs to be returned by the Configurable interface so that it gives the flexiblity to enable/enforce this through Configurable UI.
static final ConfigKey<Boolean> PasswordStrengthCheckerEnable = new ConfigKey<Boolean>("Advanced", Boolean.class, "user.password.strength.checker.enable", "false", "To enable password strength check. This will enable to check the strength and return it.", true);
If you enable this parameter then only system will check the password strength and will start return to the caller as part of API response
static final ConfigKey<Boolean> PasswordCStrengthCheckerEnforce = new ConfigKey<Boolean>("Advanced", Boolean.class, "user.password.strength.checker.enforce", "false", "To Impose the password strength. This will enforce the password rules to be verified",true);
If you enable this (With out above key value enabled enabling this will not make sense) then the system will also enforce the password strength rules for the given passwords.
it is the plugins responsibility to declare the bean that is implementing the above interface with in that plugin. Please refer (1) to know how to add a new plugin to cloudstack
Currently The integration points are at plugins those implement UserAuthenticator.
The sample Xml configuration to integrate the password checker plugin.
(From: spring-sha256salted-context.xml)
<bean id="SHA256SaltedUserAuthenticator" class="com.cloud.server.auth.SHA256SaltedUserAuthenticator">
<property name="name" value="SHA256SALT"/>
<property name="passwordCheckers" value="#{passwordCheckersRegistry.registered}"/>
</bean>