* [ADD] New encryption schema by using Defuse/php-encryption library. WARNING: work in progress

This commit is contained in:
nuxsmin
2017-02-19 23:49:34 +01:00
parent 6ee88bff04
commit 82a496cb2a
2 changed files with 33 additions and 48 deletions

View File

@@ -109,7 +109,6 @@ class Database implements AuthInterface
return $queryRes !== false
&& $Data->getQueryNumRows() === 1
&& (Hash::checkHashKey($this->UserData->getUserPass(), $queryRes->getUserPass())
|| hash_equals($queryRes->getUserPass(), crypt($this->UserData->getUserPass(), $queryRes->getUserHashSalt())));
&& Hash::checkHashKey($this->UserData->getUserPass(), $queryRes->getUserPass());
}
}

View File

@@ -366,13 +366,15 @@ class Installer
$this->DB->exec('DROP USER `' . $this->InstallData->getDbUser() . '`@`' . $this->InstallData->getDbAuthHost() . '`');
$this->DB->exec('DROP USER `' . $this->InstallData->getDbUser() . '`@`' . $this->InstallData->getDbAuthHostDns() . '`');
$this->DB->exec('DROP USER `' . $this->InstallData->getDbUser() . '`@`%`');
debugLog('Rollback');
return true;
} catch (PDOException $e) {
debugLog($e->getMessage());
return false;
}
return true;
}
/**
@@ -391,8 +393,8 @@ class Installer
__('No es posible crear la BBDD de la aplicación. Descárguela de nuevo.', false));
}
// Usar la base de datos de sysPass
try {
// Usar la base de datos de sysPass
$this->DB->exec('USE `' . $this->InstallData->getDbName() . '`');
} catch (PDOException $e) {
throw new SPException(SPException::SP_CRITICAL,
@@ -447,59 +449,43 @@ class Installer
*/
private function createAdminAccount()
{
$GroupData = new GroupData();
$GroupData->setUsergroupName('Admins');
$GroupData->setUsergroupDescription('sysPass Admins');
try {
$GroupData = new GroupData();
$GroupData->setUsergroupName('Admins');
$GroupData->setUsergroupDescription('sysPass Admins');
Group::getItem($GroupData)->add();
} catch (SPException $e) {
$this->rollback();
throw new SPException(SPException::SP_CRITICAL,
__('Error al crear el grupo "admin"', false),
__('Informe al desarrollador', false));
}
$ProfileData = new ProfileData();
$ProfileData->setUserprofileName('Admin');
$ProfileData = new ProfileData();
$ProfileData->setUserprofileName('Admin');
try {
Profile::getItem($ProfileData)->add();
} catch (SPException $e) {
$this->rollback();
throw new SPException(SPException::SP_CRITICAL,
__('Error al crear el perfil "admin"', false),
__('Informe al desarrollador', false));
}
// Datos del usuario
$UserData = new UserData();
$UserData->setUserGroupId($GroupData->getUsergroupId());
$UserData->setUserProfileId($ProfileData->getUserprofileId());
$UserData->setUserLogin($this->InstallData->getAdminLogin());
$UserData->setUserPass($this->InstallData->getAdminPass());
$UserData->setUserName('Admin');
$UserData->setUserIsAdminApp(1);
// Datos del usuario
$UserData = new UserData();
$UserData->setUserGroupId($GroupData->getUsergroupId());
$UserData->setUserProfileId($ProfileData->getUserprofileId());
$UserData->setUserLogin($this->InstallData->getAdminLogin());
$UserData->setUserPass($this->InstallData->getAdminPass());
$UserData->setUserName('Admin');
$UserData->setUserIsAdminApp(1);
try {
User::getItem($UserData)->add();
} catch (SPException $e) {
// Guardar el hash de la clave maestra
ConfigDB::setCacheConfigValue('masterPwd', Hash::hashKey($this->InstallData->getMasterPassword()));
ConfigDB::setCacheConfigValue('lastupdatempass', time());
ConfigDB::writeConfig(true);
if (!UserPass::getItem($UserData)->updateUserMPass($this->InstallData->getMasterPassword())) {
throw new SPException(SPException::SP_CRITICAL,
__('Error al actualizar la clave maestra del usuario "admin"', false),
__('Informe al desarrollador', false));
}
} catch (\Exception $e) {
$this->rollback();
throw new SPException(SPException::SP_CRITICAL,
__('Error al crear el usuario "admin"', false),
__('Informe al desarrollador', false));
}
// Guardar el hash de la clave maestra
ConfigDB::setCacheConfigValue('masterPwd', Hash::hashKey($this->InstallData->getMasterPassword()));
ConfigDB::setCacheConfigValue('lastupdatempass', time());
ConfigDB::writeConfig(true);
if (!UserPass::getItem($UserData)->updateUserMPass($this->InstallData->getMasterPassword())) {
$this->rollback();
throw new SPException(SPException::SP_CRITICAL,
__('Error al actualizar la clave maestra del usuario "admin"', false),
$e->getMessage(),
__('Informe al desarrollador', false));
}
}