N°2249 - Supportability - Updater module

This commit is contained in:
Eric
2019-10-07 17:44:17 +02:00
parent dbb5a5191b
commit f51cd65b1f
5 changed files with 62 additions and 25 deletions

View File

@@ -1886,6 +1886,40 @@ EOF
}
}
/**
* Create and store Setup authentication token
*
* @return string token
*/
public final static function CreateSetupToken()
{
if (!is_dir(APPROOT.'data'))
{
mkdir(APPROOT.'data');
}
if (!is_dir(APPROOT.'data/setup'))
{
mkdir(APPROOT.'data/setup');
}
$sUID = hash('sha256', rand());
file_put_contents(APPROOT.'data/setup/authent', $sUID);
return $sUID;
}
/**
* Verify Setup authentication token (from the request parameter 'authent')
*
* @throws \SecurityException
*/
public final static function CheckSetupToken()
{
$sAuthent = utils::ReadParam('authent', '', false, 'raw_data');
if (!file_exists(APPROOT.'data/setup/authent') || $sAuthent !== file_get_contents(APPROOT.'data/setup/authent'))
{
throw new SecurityException('Setup operations are not allowed outside of the setup');
}
}
private final static function Log($sText)
{
if (class_exists('SetupPage'))