mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-09-12 08:04:21 +08:00
Drop default admin password '12345'
Now generate one and store in 'data/_data_/_default_/admin_password.txt' And instructions at https://snappymail.eu/install.html
This commit is contained in:
parent
ff13ff688c
commit
8ef00edb86
3 changed files with 21 additions and 5 deletions
|
@ -1101,6 +1101,16 @@ class Actions
|
||||||
|
|
||||||
$oSettings = null;
|
$oSettings = null;
|
||||||
|
|
||||||
|
$passfile = APP_PRIVATE_DATA.'admin_password.txt';
|
||||||
|
$sPassword = $oConfig->Get('security', 'admin_password', '');
|
||||||
|
if (!$sPassword) {
|
||||||
|
$sPassword = \substr(\base64_encode(\random_bytes(16)), 0, 12);
|
||||||
|
\file_put_contents($passfile, $sPassword);
|
||||||
|
\chmod($passfile, 0600);
|
||||||
|
$oConfig->SetPassword($sPassword);
|
||||||
|
$oConfig->Save();
|
||||||
|
}
|
||||||
|
|
||||||
if (!$bAdmin) {
|
if (!$bAdmin) {
|
||||||
$oAccount = $this->getAccountFromToken(false);
|
$oAccount = $this->getAccountFromToken(false);
|
||||||
if ($oAccount) {
|
if ($oAccount) {
|
||||||
|
@ -1194,7 +1204,7 @@ class Actions
|
||||||
$aResult['ContactsPdoUser'] = (string)$oConfig->Get('contacts', 'pdo_user', '');
|
$aResult['ContactsPdoUser'] = (string)$oConfig->Get('contacts', 'pdo_user', '');
|
||||||
$aResult['ContactsPdoPassword'] = (string)APP_DUMMY;
|
$aResult['ContactsPdoPassword'] = (string)APP_DUMMY;
|
||||||
|
|
||||||
$aResult['WeakPassword'] = (bool)$oConfig->ValidatePassword('12345');
|
$aResult['WeakPassword'] = \is_file($passfile);
|
||||||
|
|
||||||
$aResult['PhpUploadSizes'] = array(
|
$aResult['PhpUploadSizes'] = array(
|
||||||
'upload_max_filesize' => \ini_get('upload_max_filesize'),
|
'upload_max_filesize' => \ini_get('upload_max_filesize'),
|
||||||
|
|
|
@ -255,6 +255,8 @@ trait Admin
|
||||||
$this->Logger()->AddSecret($sNewPassword);
|
$this->Logger()->AddSecret($sNewPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$passfile = APP_PRIVATE_DATA.'admin_password.txt';
|
||||||
|
|
||||||
if ($oConfig->ValidatePassword($sPassword))
|
if ($oConfig->ValidatePassword($sPassword))
|
||||||
{
|
{
|
||||||
if (0 < \strlen($sLogin))
|
if (0 < \strlen($sLogin))
|
||||||
|
@ -265,13 +267,17 @@ trait Admin
|
||||||
if (0 < \strlen(\trim($sNewPassword)))
|
if (0 < \strlen(\trim($sNewPassword)))
|
||||||
{
|
{
|
||||||
$oConfig->SetPassword($sNewPassword);
|
$oConfig->SetPassword($sNewPassword);
|
||||||
|
if (\is_file($passfile) && \trim(\file_get_contents($passfile)) !== $sNewPassword) {
|
||||||
|
\unlink($passfile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$bResult = true;
|
$bResult = $oConfig->Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->DefaultResponse(__FUNCTION__, $bResult ?
|
return $this->DefaultResponse(__FUNCTION__, $bResult
|
||||||
($oConfig->Save() ? array('Weak' => $oConfig->ValidatePassword('12345')) : false) : false);
|
? array('Weak' => \is_file($passfile))
|
||||||
|
: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function DoAdminDomainLoad() : array
|
public function DoAdminDomainLoad() : array
|
||||||
|
|
|
@ -158,7 +158,7 @@ class Application extends \RainLoop\Config\AbstractConfig
|
||||||
'openpgp' => array(false),
|
'openpgp' => array(false),
|
||||||
|
|
||||||
'admin_login' => array('admin', 'Login and password for web admin panel'),
|
'admin_login' => array('admin', 'Login and password for web admin panel'),
|
||||||
'admin_password' => array(\password_hash('12345', PASSWORD_DEFAULT)),
|
'admin_password' => array(''),
|
||||||
'allow_admin_panel' => array(true, 'Access settings'),
|
'allow_admin_panel' => array(true, 'Access settings'),
|
||||||
'allow_two_factor_auth' => array(false),
|
'allow_two_factor_auth' => array(false),
|
||||||
'force_two_factor_auth' => array(false),
|
'force_two_factor_auth' => array(false),
|
||||||
|
|
Loading…
Add table
Reference in a new issue