‪TYPO3CMS  ‪main
NoopPasswordHash.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
22 
29 {
30  protected const ‪PREFIX = '$SHA1$';
31 
32  public function ‪__construct()
33  {
34  if (!‪Environment::getContext()->isTesting()) {
35  throw new \LogicException(
36  sprintf('The password hashing algorithm %s must not be used outside of testing context!', __CLASS__),
37  1655551062
38  );
39  }
40  }
41 
42  public function ‪checkPassword(string $plainPW, string $saltedHashPW): bool
43  {
44  return $this->‪getHashedPassword($plainPW) === $saltedHashPW;
45  }
46 
47  public function ‪isAvailable(): bool
48  {
49  return true;
50  }
51 
52  public function ‪getHashedPassword(string $password): string
53  {
54  return self::PREFIX . sha1($password);
55  }
56 
57  public function ‪isHashUpdateNeeded(string $passString): bool
58  {
59  return false;
60  }
61 
62  public function ‪isValidSaltedPW(string $saltedPW): bool
63  {
64  return !strncmp(self::PREFIX, $saltedPW, strlen(self::PREFIX));
65  }
66 
67  public static function ‪registerNoopPasswordHash(): void
68  {
69  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['availablePasswordHashAlgorithms'][__CLASS__] = __CLASS__;
70  }
71 
72  public static function ‪unregisterNoopPasswordHash(): void
73  {
74  unset(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['availablePasswordHashAlgorithms'][__CLASS__]);
75  }
76 }
‪TYPO3\CMS\Core\Tests\Unit\Authentication\Mfa\Provider\Fixtures\Crypto\PasswordHashing
Definition: NoopPasswordHash.php:18
‪TYPO3\CMS\Core\Tests\Unit\Authentication\Mfa\Provider\Fixtures\Crypto\PasswordHashing\NoopPasswordHash\unregisterNoopPasswordHash
‪static unregisterNoopPasswordHash()
Definition: NoopPasswordHash.php:72
‪TYPO3\CMS\Core\Tests\Unit\Authentication\Mfa\Provider\Fixtures\Crypto\PasswordHashing\NoopPasswordHash
Definition: NoopPasswordHash.php:29
‪TYPO3\CMS\Core\Tests\Unit\Authentication\Mfa\Provider\Fixtures\Crypto\PasswordHashing\NoopPasswordHash\checkPassword
‪checkPassword(string $plainPW, string $saltedHashPW)
Definition: NoopPasswordHash.php:42
‪TYPO3\CMS\Core\Tests\Unit\Authentication\Mfa\Provider\Fixtures\Crypto\PasswordHashing\NoopPasswordHash\registerNoopPasswordHash
‪static registerNoopPasswordHash()
Definition: NoopPasswordHash.php:67
‪TYPO3\CMS\Core\Tests\Unit\Authentication\Mfa\Provider\Fixtures\Crypto\PasswordHashing\NoopPasswordHash\getHashedPassword
‪getHashedPassword(string $password)
Definition: NoopPasswordHash.php:52
‪TYPO3\CMS\Core\Tests\Unit\Authentication\Mfa\Provider\Fixtures\Crypto\PasswordHashing\NoopPasswordHash\__construct
‪__construct()
Definition: NoopPasswordHash.php:32
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Core\Tests\Unit\Authentication\Mfa\Provider\Fixtures\Crypto\PasswordHashing\NoopPasswordHash\isAvailable
‪isAvailable()
Definition: NoopPasswordHash.php:47
‪TYPO3\CMS\Core\Tests\Unit\Authentication\Mfa\Provider\Fixtures\Crypto\PasswordHashing\NoopPasswordHash\isHashUpdateNeeded
‪isHashUpdateNeeded(string $passString)
Definition: NoopPasswordHash.php:57
‪TYPO3\CMS\Core\Tests\Unit\Authentication\Mfa\Provider\Fixtures\Crypto\PasswordHashing\NoopPasswordHash\isValidSaltedPW
‪isValidSaltedPW(string $saltedPW)
Definition: NoopPasswordHash.php:62
‪TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashInterface
Definition: PasswordHashInterface.php:25
‪TYPO3\CMS\Core\Core\Environment\getContext
‪static getContext()
Definition: Environment.php:128
‪TYPO3\CMS\Core\Tests\Unit\Authentication\Mfa\Provider\Fixtures\Crypto\PasswordHashing\NoopPasswordHash\PREFIX
‪const PREFIX
Definition: NoopPasswordHash.php:30