mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-02-23 14:26:18 +08:00
Merge pull request #948 from mondediefr/master
Add support for SHA256-CRYPT and SHA512-CRYPT crypt schemes #939
This commit is contained in:
commit
93cc4ca3cc
2 changed files with 10 additions and 1 deletions
|
@ -258,6 +258,7 @@ class ChangePasswordPostfixAdminDriver implements \RainLoop\Providers\ChangePass
|
||||||
private function cryptPassword($sPassword, $oPdo)
|
private function cryptPassword($sPassword, $oPdo)
|
||||||
{
|
{
|
||||||
$sResult = '';
|
$sResult = '';
|
||||||
|
$sSalt = substr(str_shuffle('./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'), 0, 16);
|
||||||
switch ($this->sEncrypt)
|
switch ($this->sEncrypt)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
@ -279,6 +280,14 @@ class ChangePasswordPostfixAdminDriver implements \RainLoop\Providers\ChangePass
|
||||||
$sResult = crypt($sPassword);
|
$sResult = crypt($sPassword);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'SHA256-CRYPT':
|
||||||
|
$sResult = '{SHA256-CRYPT}' . crypt($sPassword,'$5$'.$sSalt);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'SHA512-CRYPT':
|
||||||
|
$sResult = '{SHA512-CRYPT}' . crypt($sPassword,'$6$'.$sSalt);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'mysql_encrypt':
|
case 'mysql_encrypt':
|
||||||
$oStmt = $oPdo->prepare('SELECT ENCRYPT(?) AS encpass');
|
$oStmt = $oPdo->prepare('SELECT ENCRYPT(?) AS encpass');
|
||||||
if ($oStmt->execute(array($sPassword)))
|
if ($oStmt->execute(array($sPassword)))
|
||||||
|
|
|
@ -84,7 +84,7 @@ class PostfixAdminChangePasswordPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
->SetDefaultValue(''),
|
->SetDefaultValue(''),
|
||||||
\RainLoop\Plugins\Property::NewInstance('encrypt')->SetLabel('Encrypt')
|
\RainLoop\Plugins\Property::NewInstance('encrypt')->SetLabel('Encrypt')
|
||||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::SELECTION)
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::SELECTION)
|
||||||
->SetDefaultValue(array('md5crypt', 'md5', 'system', 'cleartext', 'mysql_encrypt'))
|
->SetDefaultValue(array('md5crypt', 'md5', 'system', 'cleartext', 'mysql_encrypt', 'SHA256-CRYPT', 'SHA512-CRYPT'))
|
||||||
->SetDescription('In what way do you want the passwords to be crypted ?'),
|
->SetDescription('In what way do you want the passwords to be crypted ?'),
|
||||||
\RainLoop\Plugins\Property::NewInstance('allowed_emails')->SetLabel('Allowed emails')
|
\RainLoop\Plugins\Property::NewInstance('allowed_emails')->SetLabel('Allowed emails')
|
||||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT)
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT)
|
||||||
|
|
Loading…
Reference in a new issue