‪TYPO3CMS  9.5
AbstractAuthenticationService.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 
22 
27 {
33  public ‪$pObj;
34 
40  public ‪$mode;
41 
47  public ‪$login = [];
48 
54  public ‪$authInfo = [];
55 
61  public ‪$db_user = [];
62 
68  public ‪$db_groups = [];
69 
75  public ‪$writeAttemptLog = false;
76 
85  public function ‪initAuth(‪$mode, $loginData, ‪$authInfo, ‪$pObj)
86  {
87  $this->pObj = ‪$pObj;
88  // Sub type
89  $this->mode = ‪$mode;
90  $this->login = $loginData;
91  $this->authInfo = ‪$authInfo;
92  $this->db_user = $this->‪getServiceOption('db_user', ‪$authInfo['db_user'] ?? [], false);
93  $this->db_groups = $this->‪getServiceOption('db_groups', ‪$authInfo['db_groups'] ?? [], false);
94  $this->writeAttemptLog = $this->pObj->writeAttemptLog ?? true;
95  }
96 
106  public function ‪compareUident(array $user, array $loginData, $passwordCompareStrategy = '')
107  {
108  trigger_error('This method will be removed in TYPO3 v10.0.', E_USER_DEPRECATED);
109  return $this->pObj->compareUident($user, $loginData, $passwordCompareStrategy);
110  }
111 
125  public function ‪writelog($type, $action, ‪$error, $details_nr, $details, $data, $tablename = '', $recuid = '', $recpid = '')
126  {
127  if ($this->writeAttemptLog) {
128  $this->pObj->writelog($type, $action, ‪$error, $details_nr, $details, $data, $tablename, $recuid, $recpid);
129  }
130  }
131 
140  public function ‪fetchUserRecord($username, $extraWhere = '', $dbUserSetup = '')
141  {
142  $dbUser = is_array($dbUserSetup) ? $dbUserSetup : ‪$this->db_user;
143  $user = false;
144  if ($username || $extraWhere) {
145  $query = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($dbUser['table']);
146  $query->getRestrictions()->removeAll()
147  ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
148  $constraints = array_filter([
149  ‪QueryHelper::stripLogicalOperatorPrefix($dbUser['check_pid_clause']),
150  ‪QueryHelper::stripLogicalOperatorPrefix($dbUser['enable_clause']),
152  ]);
153  if (!empty($username)) {
154  array_unshift(
155  $constraints,
156  $query->expr()->eq(
157  $dbUser['username_column'],
158  $query->createNamedParameter($username, \PDO::PARAM_STR)
159  )
160  );
161  }
162  $user = $query->select('*')
163  ->from($dbUser['table'])
164  ->where(...$constraints)
165  ->execute()
166  ->fetch();
167  }
168  return $user;
169  }
170 }
‪TYPO3\CMS\Core\Authentication\AbstractAuthenticationService\compareUident
‪bool compareUident(array $user, array $loginData, $passwordCompareStrategy='')
Definition: AbstractAuthenticationService.php:99
‪TYPO3\CMS\Core\Authentication\AbstractAuthenticationService\initAuth
‪initAuth($mode, $loginData, $authInfo, $pObj)
Definition: AbstractAuthenticationService.php:78
‪TYPO3\CMS\Core\Authentication\AbstractAuthenticationService\$writeAttemptLog
‪bool $writeAttemptLog
Definition: AbstractAuthenticationService.php:68
‪TYPO3\CMS\Core\Authentication\AbstractAuthenticationService\fetchUserRecord
‪mixed fetchUserRecord($username, $extraWhere='', $dbUserSetup='')
Definition: AbstractAuthenticationService.php:133
‪TYPO3\CMS\Core\Authentication
Definition: AbstractAuthenticationService.php:2
‪TYPO3\CMS\Core\Authentication\AbstractAuthenticationService\writelog
‪writelog($type, $action, $error, $details_nr, $details, $data, $tablename='', $recuid='', $recpid='')
Definition: AbstractAuthenticationService.php:118
‪TYPO3\CMS\Core\Authentication\AbstractAuthenticationService
Definition: AbstractAuthenticationService.php:27
‪TYPO3\CMS\Core\Authentication\AbstractAuthenticationService\$db_groups
‪array $db_groups
Definition: AbstractAuthenticationService.php:62
‪TYPO3\CMS\Core\Database\Query\QueryHelper
Definition: QueryHelper.php:30
‪TYPO3\CMS\Core\Authentication\AbstractAuthenticationService\$mode
‪string $mode
Definition: AbstractAuthenticationService.php:38
‪TYPO3\CMS\Core\Authentication\AbstractAuthenticationService\$db_user
‪array $db_user
Definition: AbstractAuthenticationService.php:56
‪TYPO3\CMS\Core\Authentication\AbstractAuthenticationService\$pObj
‪AbstractUserAuthentication $pObj
Definition: AbstractAuthenticationService.php:32
‪TYPO3\CMS\Core\Database\Query\QueryHelper\stripLogicalOperatorPrefix
‪static string stripLogicalOperatorPrefix(string $constraint)
Definition: QueryHelper.php:163
‪TYPO3\CMS\Core\Authentication\AbstractAuthenticationService\$authInfo
‪array $authInfo
Definition: AbstractAuthenticationService.php:50
‪TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction
Definition: DeletedRestriction.php:26
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Service\AbstractService
Definition: AbstractService.php:29
‪TYPO3\CMS\Core\Authentication\AbstractAuthenticationService\$login
‪array $login
Definition: AbstractAuthenticationService.php:44
‪TYPO3\CMS\Core\Service\AbstractService\$error
‪array $error
Definition: AbstractService.php:67
‪TYPO3\CMS\Core\Authentication\AbstractUserAuthentication
Definition: AbstractUserAuthentication.php:51
‪TYPO3\CMS\Core\Service\AbstractService\getServiceOption
‪mixed getServiceOption($optionName, $defaultValue='', $includeDefaultConfig=true)
Definition: AbstractService.php:147