TYPO3 CMS  TYPO3_6-2
SaltedPasswordsUtility.php
Go to the documentation of this file.
1 <?php
3 
24 
28  const EXTKEY = 'saltedpasswords';
29 
37  $userCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
38  '*',
39  'be_users',
40  'password != \'\''
41  . ' AND password NOT LIKE ' . $GLOBALS['TYPO3_DB']->fullQuoteStr('$%', 'be_users')
42  . ' AND password NOT LIKE ' . $GLOBALS['TYPO3_DB']->fullQuoteStr('M$%', 'be_users')
43  );
44  return $userCount;
45  }
46 
55  static public function returnExtConf($mode = TYPO3_MODE) {
56  $currentConfiguration = self::returnExtConfDefaults();
57  if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['saltedpasswords'])) {
58  $extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['saltedpasswords']);
59  // Merge default configuration with modified configuration:
60  if (isset($extensionConfiguration[$mode . '.'])) {
61  $currentConfiguration = array_merge($currentConfiguration, $extensionConfiguration[$mode . '.']);
62  }
63  }
64  return $currentConfiguration;
65  }
66 
75  public function feloginForgotPasswordHook(array &$params, \TYPO3\CMS\Felogin\Controller\FrontendLoginController $pObj) {
76  if (self::isUsageEnabled('FE')) {
78  $params['newPassword'] = $objInstanceSaltedPW->getHashedPassword($params['newPassword']);
79  }
80  }
81 
87  static public function returnExtConfDefaults() {
88  return array(
89  'onlyAuthService' => '0',
90  'forceSalted' => '0',
91  'updatePasswd' => '1',
92  'saltedPWHashingMethod' => 'TYPO3\\CMS\\Saltedpasswords\\Salt\\PhpassSalt',
93  'enabled' => '1'
94  );
95  }
96 
104  static public function getDefaultSaltingHashingMethod($mode = TYPO3_MODE) {
105  $extConf = self::returnExtConf($mode);
106  $classNameToUse = 'TYPO3\\CMS\\Saltedpasswords\\Salt\\Md5Salt';
107  if (in_array($extConf['saltedPWHashingMethod'], array_keys(\TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getRegisteredSaltedHashingMethods()))) {
108  $classNameToUse = $extConf['saltedPWHashingMethod'];
109  }
110  return $classNameToUse;
111  }
112 
120  static public function isUsageEnabled($mode = TYPO3_MODE) {
121  // Login Security Level Recognition
122  $extConf = self::returnExtConf($mode);
123  $securityLevel = $GLOBALS['TYPO3_CONF_VARS'][$mode]['loginSecurityLevel'];
124  if ($mode == 'BE') {
125  return TRUE;
126  } elseif ($mode == 'FE' && $extConf['enabled']) {
127  return \TYPO3\CMS\Core\Utility\GeneralUtility::inList('normal,rsa', $securityLevel);
128  }
129  return FALSE;
130  }
131 
132 }
feloginForgotPasswordHook(array &$params, \TYPO3\CMS\Felogin\Controller\FrontendLoginController $pObj)
static getSaltingInstance($saltedHash='', $mode=TYPO3_MODE)
Definition: SaltFactory.php:83
const TYPO3_MODE
Definition: init.php:40
$extConf
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]