mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Added config option for minimum passlength
Disable broken PasswordWeaknessCheck See https://github.com/the-djmaze/snappymail/issues/51#issuecomment-790582737
This commit is contained in:
parent
72988972a7
commit
96ea4fdf0a
1 changed files with 16 additions and 4 deletions
|
|
@ -79,7 +79,13 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
|
|
||||||
public function configMapping() : array
|
public function configMapping() : array
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [
|
||||||
|
\RainLoop\Plugins\Property::NewInstance("pass_min_length")
|
||||||
|
->SetLabel('Password minimum length')
|
||||||
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::INT)
|
||||||
|
->SetDescription('Minimum length of the password')
|
||||||
|
->SetDefaultValue(10),
|
||||||
|
];
|
||||||
foreach ($this->getSupportedDrivers(true) as $name => $class) {
|
foreach ($this->getSupportedDrivers(true) as $name => $class) {
|
||||||
$result[] = \RainLoop\Plugins\Property::NewInstance("driver_{$name}_enabled")
|
$result[] = \RainLoop\Plugins\Property::NewInstance("driver_{$name}_enabled")
|
||||||
->SetLabel('Enable ' . $class::NAME)
|
->SetLabel('Enable ' . $class::NAME)
|
||||||
|
|
@ -112,18 +118,19 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
$sPasswordForCheck = \trim($sNewPassword);
|
$sPasswordForCheck = \trim($sNewPassword);
|
||||||
if (10 > \strlen($sPasswordForCheck)) {
|
if ($this->Config()->Get('plugin', 'pass_min_length', 10) > \strlen($sPasswordForCheck)) {
|
||||||
throw new ClientException(static::NewPasswordShort, null, $oActions->StaticI18N('NOTIFICATIONS/NEW_PASSWORD_SHORT'));
|
throw new ClientException(static::NewPasswordShort, null, $oActions->StaticI18N('NOTIFICATIONS/NEW_PASSWORD_SHORT'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\MailSo\Base\Utils::PasswordWeaknessCheck($sPasswordForCheck)) {
|
if (!static::PasswordWeaknessCheck($sPasswordForCheck)) {
|
||||||
throw new ClientException(static::NewPasswordWeak, null, $oActions->StaticI18N('NOTIFICATIONS/NEW_PASSWORD_WEAK'));
|
throw new ClientException(static::NewPasswordWeak, null, $oActions->StaticI18N('NOTIFICATIONS/NEW_PASSWORD_WEAK'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$bResult = false;
|
$bResult = false;
|
||||||
$oConfig = $this->Config();
|
$oConfig = $this->Config();
|
||||||
foreach ($this->getSupportedDrivers() as $name => $class) {
|
foreach ($this->getSupportedDrivers() as $name => $class) {
|
||||||
if (\RainLoop\Plugins\Helper::ValidateWildcardValues($oAccount->Email(), $oConfig->Get('plugin', "driver_{$name}_allowed_emails"))) {
|
$sFoundedValue = '';
|
||||||
|
if (\RainLoop\Plugins\Helper::ValidateWildcardValues($oAccount->Email(), $oConfig->Get('plugin', "driver_{$name}_allowed_emails"), $sFoundedValue)) {
|
||||||
$name = $class::NAME;
|
$name = $class::NAME;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -185,4 +192,9 @@ class ChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
return $sPassword;
|
return $sPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function PasswordWeaknessCheck(string $sPassword) : bool
|
||||||
|
{
|
||||||
|
return !!preg_match('/111|1234|password|abc|qwerty|monkey|letmein|dragon|baseball|iloveyou|trustno1|sunshine|master|welcome|shadow|ashley|football|jesus|michael|ninja|mustang|vkontakte/i', $sPassword);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue