Commit bf61d8a1 authored by Marc Egger's avatar Marc Egger
Browse files

Refs #12516 use legacy password hashing for Typo3 v8

parent 8a350d89
Pipeline #5222 passed with stages
in 3 minutes and 34 seconds
......@@ -52,8 +52,28 @@ class T3Handler {
*/
public static function getHash($newPassword) {
$type = Config::get(SYSTEM_PASWORD_HASH_TYPE) ?? 'PASSWORD_ARGON2I';
// Typo3 version <=8
// Legacy code based on https://docs.typo3.org/typo3cms/extensions/saltedpasswords/8.7/DevelopersGuide/Index.html
self::t3AutoloadIfNotRunning();
if (!class_exists('\TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory')
&& class_exists('\TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility')
&& class_exists('\TYPO3\CMS\Saltedpasswords\Salt\SaltFactory')) {
$saltedPassword = null;
restore_error_handler(); // Restore T3 ErrorHandler. T3 throws exceptions - those should be handled by T3!
if (\TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility::isUsageEnabled('FE')) {
$objSalt = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance(NULL);
if (is_object($objSalt)) {
$saltedPassword = $objSalt->getHashedPassword($newPassword);
}
}
Support::setQfqErrorHandler(); // Activate QFQ ErrorHandler again.
if (!is_null($saltedPassword)) {
return $saltedPassword;
}
}
// Typo3 version >=9
$type = Config::get(SYSTEM_PASWORD_HASH_TYPE) ?? 'PASSWORD_ARGON2I';
if ($type === 'PASSWORD_ARGON2I') {
// Use Argon2i algorithm (with current default options of typo3 in year 2020)
$saltedPassword = password_hash($newPassword, PASSWORD_ARGON2I, ['memory_cost' => 65536, 'time_cost' => 16, 'threads' => 1]);
......@@ -64,7 +84,6 @@ class T3Handler {
} else {
Thrower::userFormException('Password hashing type not recognized.', 'The following password hashing type is not recognized: ' . $type);
}
return $saltedPassword;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment