‪TYPO3CMS  9.5
SaltedPasswordsUtility.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 
27 {
33  const ‪EXTKEY = 'saltedpasswords';
34 
42  {
43  trigger_error('SaltedPasswordsUtility::getNumberOfBackendUsersWithInsecurePassword() is obsolete and will be removed in TYPO3 v10.0.', E_USER_DEPRECATED);
44  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
45  $queryBuilder->getRestrictions()->removeAll();
46 
47  $userCount = $queryBuilder
48  ->count('*')
49  ->from('be_users')
50  ->where(
51  $queryBuilder->expr()->neq('password', $queryBuilder->createNamedParameter('', \PDO::PARAM_STR)),
52  $queryBuilder->expr()->notLike('password', $queryBuilder->createNamedParameter('$%', \PDO::PARAM_STR)),
53  $queryBuilder->expr()->notLike('password', $queryBuilder->createNamedParameter('M$%', \PDO::PARAM_STR))
54  )
55  ->execute()
56  ->fetchColumn();
57 
58  return $userCount;
59  }
60 
68  public static function ‪returnExtConf($mode = TYPO3_MODE)
69  {
70  trigger_error('SaltedPasswordsUtility::returnExtConf() is obsolete and will be removed in TYPO3 v10.0.', E_USER_DEPRECATED);
71  $currentConfiguration = ‪self::returnExtConfDefaults();
72  if (isset(‪$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['saltedpasswords'])) {
73  $extensionConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('saltedpasswords');
74  // Merge default configuration with modified configuration:
75  if (isset($extensionConfiguration[$mode])) {
76  $currentConfiguration = array_merge($currentConfiguration, $extensionConfiguration[$mode]);
77  }
78  }
79  return $currentConfiguration;
80  }
81 
88  public static function ‪returnExtConfDefaults()
89  {
90  trigger_error('SaltedPasswordsUtility::returnExtConfDefaults() is obsolete and will be removed in TYPO3 v10.0.', E_USER_DEPRECATED);
91  return [
92  'saltedPWHashingMethod' => \TYPO3\CMS\Core\Crypto\PasswordHashing\PhpassPasswordHash::class,
93  ];
94  }
95 
104  public static function ‪getDefaultSaltingHashingMethod($mode = TYPO3_MODE)
105  {
106  trigger_error('SaltedPasswordsUtility::getDefaultSaltingHashingMethod() is obsolete and will be removed in TYPO3 v10.0.', E_USER_DEPRECATED);
108  $classNameToUse = \TYPO3\CMS\Core\Crypto\PasswordHashing\Md5PasswordHash::class;
109  if (in_array(
110  ‪$extConf['saltedPWHashingMethod'],
111  \‪TYPO3\CMS\Core\Crypto\PasswordHashing\‪PasswordHashFactory::getRegisteredSaltedHashingMethods(),
112  true
113  )) {
114  $classNameToUse = ‪$extConf['saltedPWHashingMethod'];
115  }
116  return $classNameToUse;
117  }
118 
126  public static function ‪isUsageEnabled()
127  {
128  trigger_error(
129  'SaltedPasswordsUtility::isUsageEnabled() now always returns true and will be removed with TYPO3 v10.0.',
130  E_USER_DEPRECATED
131  );
132  return true;
133  }
134 }
‪TYPO3\CMS\Core\Configuration\ExtensionConfiguration
Definition: ExtensionConfiguration.php:42
‪TYPO3\CMS\Core\Crypto\PasswordHashing
Definition: AbstractComposedSalt.php:3
‪TYPO3
‪TYPO3\CMS\Core\Crypto\PasswordHashing\SaltedPasswordsUtility\returnExtConfDefaults
‪static array returnExtConfDefaults()
Definition: SaltedPasswordsUtility.php:88
‪TYPO3\CMS\Core\Crypto\PasswordHashing\SaltedPasswordsUtility\getNumberOfBackendUsersWithInsecurePassword
‪static int getNumberOfBackendUsersWithInsecurePassword()
Definition: SaltedPasswordsUtility.php:41
‪TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory\getRegisteredSaltedHashingMethods
‪static array getRegisteredSaltedHashingMethods()
Definition: PasswordHashFactory.php:145
‪TYPO3\CMS\Core\Crypto\PasswordHashing\SaltedPasswordsUtility\returnExtConf
‪static array returnExtConf($mode=TYPO3_MODE)
Definition: SaltedPasswordsUtility.php:68
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Crypto\PasswordHashing\SaltedPasswordsUtility\EXTKEY
‪const EXTKEY
Definition: SaltedPasswordsUtility.php:33
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪$extConf
‪$extConf
Definition: ext_localconf.php:50
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Crypto\PasswordHashing\SaltedPasswordsUtility\getDefaultSaltingHashingMethod
‪static string getDefaultSaltingHashingMethod($mode=TYPO3_MODE)
Definition: SaltedPasswordsUtility.php:104
‪TYPO3\CMS\Core\Crypto\PasswordHashing\SaltedPasswordsUtility
Definition: SaltedPasswordsUtility.php:27
‪TYPO3\CMS\Core\Crypto\PasswordHashing\SaltedPasswordsUtility\isUsageEnabled
‪static bool isUsageEnabled()
Definition: SaltedPasswordsUtility.php:126