ChangePasswordPlugin also use Have I Been Pwned

This commit is contained in:
the-djmaze 2024-04-22 17:38:05 +02:00
parent 6739ec21c8
commit b4dbf249ee
12 changed files with 76 additions and 42 deletions

View file

@ -7,9 +7,9 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
{
const
NAME = 'Change Password',
VERSION = '2.37',
RELEASE = '2024-03-29',
REQUIRED = '2.36.0',
VERSION = '2.38',
RELEASE = '2024-04-22',
REQUIRED = '2.36.1',
CATEGORY = 'Security',
DESCRIPTION = 'Extension to allow users to change their passwords';
@ -18,7 +18,8 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
CouldNotSaveNewPassword = 130,
CurrentPasswordIncorrect = 131,
NewPasswordShort = 132,
NewPasswordWeak = 133;
NewPasswordWeak = 133,
NewPasswordHibp = 134;
public function Init() : void
{
@ -103,18 +104,23 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
public function configMapping() : array
{
$result = [
\RainLoop\Plugins\Property::NewInstance("pass_min_length")
\RainLoop\Plugins\Property::NewInstance('pass_min_length')
->SetLabel('Password minimum length')
->SetType(\RainLoop\Enumerations\PluginPropertyType::INT)
->SetDescription('Minimum length of the password')
->SetDefaultValue(10)
->SetAllowedInJs(true),
\RainLoop\Plugins\Property::NewInstance("pass_min_strength")
\RainLoop\Plugins\Property::NewInstance('pass_min_strength')
->SetLabel('Password minimum strength')
->SetType(\RainLoop\Enumerations\PluginPropertyType::INT)
->SetDescription('Minimum strength of the password in %')
->SetDefaultValue(70)
->SetAllowedInJs(true),
\RainLoop\Plugins\Property::NewInstance('check_hibp')
->SetLabel('Check Have I Been Pwned')
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
->SetDescription('Check if new passphrase is in a data breach')
->SetDefaultValue(false),
];
foreach ($this->getSupportedDrivers(true) as $name => $class) {
$group = new \RainLoop\Plugins\PropertyCollection($name);
@ -160,6 +166,9 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
throw new ClientException(static::NewPasswordWeak, null, $oActions->StaticI18N('NOTIFICATIONS/NEW_PASSWORD_WEAK'));
}
$oNewPassword = new \SnappyMail\SensitiveString($sNewPassword);
if ($this->Config()->Get('plugin', 'check_hibp', false) && \SnappyMail\Hibp::password($oNewPassword)) {
throw new ClientException(static::NewPasswordHibp, null, $oActions->StaticI18N('NOTIFICATIONS/NEW_PASSWORD_HIBP'));
}
$bResult = false;
$oConfig = $this->Config();

View file

@ -10,3 +10,4 @@ CURRENT_PASSWORD_INCORRECT = "Aktuelles Passwort falsch"
CURRENT_PASSWORD_INCORRECT = "Aktuelles Passwort falsch"
NEW_PASSWORD_SHORT = "Passwort ist zu kurz"
NEW_PASSWORD_WEAK = "Passwort ist zu einfach"
NEW_PASSWORD_HIBP = "Passwort gefunden in Have I Been Pwned"

View file

@ -10,3 +10,4 @@ COULD_NOT_SAVE_NEW_PASSWORD = "Could not save new password"
CURRENT_PASSWORD_INCORRECT = "Current password incorrect"
NEW_PASSWORD_SHORT = "Password is too short"
NEW_PASSWORD_WEAK = "Password is too easy"
NEW_PASSWORD_HIBP = "Password found in Have I Been Pwned"

View file

@ -10,3 +10,4 @@ COULD_NOT_SAVE_NEW_PASSWORD = "Could not save new password"
CURRENT_PASSWORD_INCORRECT = "Current password incorrect"
NEW_PASSWORD_SHORT = "Password is too short"
NEW_PASSWORD_WEAK = "Password is too easy"
NEW_PASSWORD_HIBP = "Password found in Have I Been Pwned"

View file

@ -10,3 +10,4 @@ COULD_NOT_SAVE_NEW_PASSWORD = "Could not save new password"
CURRENT_PASSWORD_INCORRECT = "Current password incorrect"
NEW_PASSWORD_SHORT = "Password is too short"
NEW_PASSWORD_WEAK = "Password is too easy"
NEW_PASSWORD_HIBP = "Password found in Have I Been Pwned"

View file

@ -10,3 +10,4 @@ COULD_NOT_SAVE_NEW_PASSWORD = "No se puede guardar la nueva contraseña"
CURRENT_PASSWORD_INCORRECT = "La contraseña actual es incorrecta"
NEW_PASSWORD_SHORT = "La contraseña es muy corta"
NEW_PASSWORD_WEAK = "La contraseña es muy fácil"
NEW_PASSWORD_HIBP = "Contraseña encontrada en Have I Been Pwned"

View file

@ -10,3 +10,4 @@ COULD_NOT_SAVE_NEW_PASSWORD = "Impossible d'enregistrer le nouveau mot de passe"
CURRENT_PASSWORD_INCORRECT = "Le mot de passe actuel est incorrect"
NEW_PASSWORD_SHORT = "Le mot de passe est trop court"
NEW_PASSWORD_WEAK = "Le mot de passe n'est pas assez fort"
NEW_PASSWORD_HIBP = "Mot de passe trouvé dans Have I Been Pwned"

View file

@ -10,3 +10,4 @@ COULD_NOT_SAVE_NEW_PASSWORD = "Non è stato possibile salvare la nuova password"
CURRENT_PASSWORD_INCORRECT = "La password attuale non è corretta"
NEW_PASSWORD_SHORT = "La password scelta è troppo breve"
NEW_PASSWORD_WEAK = "La password scelta non è abbastanza complessa"
NEW_PASSWORD_HIBP = "Password trovata in Have I Been Pwned"

View file

@ -10,3 +10,4 @@ COULD_NOT_SAVE_NEW_PASSWORD = "Nieuwe wachtwoord kon niet opgeslagen worden"
CURRENT_PASSWORD_INCORRECT = "Huidig wachtwoord onjuist"
NEW_PASSWORD_SHORT = "Wachtwoord is te kort"
NEW_PASSWORD_WEAK = "Wachtwoord is te makkelijk"
NEW_PASSWORD_HIBP = "Wachtwoord gevonden in Have I Been Pwned"

View file

@ -10,3 +10,4 @@ COULD_NOT_SAVE_NEW_PASSWORD = "无法保存新密码"
CURRENT_PASSWORD_INCORRECT = "当前密码不正确"
NEW_PASSWORD_SHORT = "密码太短"
NEW_PASSWORD_WEAK = "密码过于简单"
NEW_PASSWORD_HIBP = "在 Have I Been Pwned 中找到密码"