00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00033 class tx_sv_auth extends tx_sv_authbase {
00034
00035
00041 function getUser() {
00042 $user = false;
00043
00044 if ($this->login['uident'] && $this->login['uname']) {
00045
00046
00047 $dbres = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00048 '*',
00049 $this->db_user['table'],
00050 $this->db_user['username_column'].'="'.$GLOBALS['TYPO3_DB']->quoteStr($this->login['uname'], $this->db_user['table']).'"'.
00051 $this->db_user['check_pid_clause'].
00052 $this->db_user['enable_clause']
00053 );
00054
00055 if ($dbres) {
00056 $user = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($dbres);
00057 $GLOBALS['TYPO3_DB']->sql_free_result($dbres);
00058 }
00059
00060 if(!is_array($user)) {
00061
00062 if ($this->pObj->writeAttemptLog) {
00063 $this->writelog(255,3,3,2,
00064 "Login-attempt from %s (%s), username '%s' not found!!",
00065 Array($this->info['REMOTE_ADDR'], $this->info['REMOTE_HOST'], $this->login['uname']));
00066 }
00067 } else {
00068 if ($this->writeDevLog) t3lib_div::devLog('User found: '.t3lib_div::arrayToLogString($user, array($this->db_user['userid_column'],$this->db_user['username_column'])), 'tx_sv_auth');
00069 }
00070 }
00071 return $user;
00072 }
00073
00082 function authUser($user) {
00083 $OK = 100;
00084
00085 if ($this->login['uident'] && $this->login['uname']) {
00086 $OK = false;
00087
00088
00089 switch ($this->info['security_level']) {
00090 case 'superchallenged':
00091 case 'challenged':
00092 if ((string)$this->login['uident'] == (string)md5($user[$this->db_user['username_column']].':'.$user[$this->db_user['userident_column']].':'.$this->login['chalvalue'])) {
00093 $OK = true;
00094 };
00095 break;
00096 default:
00097 if ((string)$this->login['uident'] == (string)$user[$this->db_user['userident_column']]) {
00098 $OK = true;
00099 };
00100 break;
00101 }
00102
00103 if(!$OK) {
00104
00105 if ($this->writeAttemptLog) {
00106 $this->writelog(255,3,3,1,
00107 "Login-attempt from %s (%s), username '%s', password not accepted!",
00108 Array($this->info['REMOTE_ADDR'], $this->info['REMOTE_HOST'], $this->login['uname']));
00109 }
00110 if ($this->writeDevLog) t3lib_div::devLog('Password not accepted: '.$this->login['uident'], 'tx_sv_auth', 2);
00111 }
00112
00113
00114 if ($OK && $user['lockToDomain'] && $user['lockToDomain']!=$this->info['HTTP_HOST']) {
00115
00116 if ($this->writeAttemptLog) {
00117 $this->writelog(255,3,3,1,
00118 "Login-attempt from %s (%s), username '%s', locked domain '%s' did not match '%s'!",
00119 Array($this->info['REMOTE_ADDR'], $this->info['REMOTE_HOST'], $user[$this->db_user['username_column']], $user['lockToDomain'], $this->info['HTTP_HOST']));
00120 }
00121 $OK = false;
00122 }
00123 } elseif ($info['userSession'][$this->db_user['userid_column']]) {
00124
00125 $OK = true;
00126 }
00127
00128 return $OK;
00129 }
00130
00131
00140 function getGroups($user, $knownGroups) {
00141
00142 $groupDataArr = array();
00143
00144 if($this->mode=='getGroupsFE') {
00145
00146 $groups = array();
00147
00148 if (is_array($user) && $user[$this->db_user['usergroup_column']]) {
00149 $groups = t3lib_div::intExplode(',',$user[$this->db_user['usergroup_column']]);
00150 }
00151
00152
00153
00154 if (is_array($this->pObj->TYPO3_CONF_VARS['FE']['IPmaskMountGroups'])) {
00155 foreach($this->pObj->TYPO3_CONF_VARS['FE']['IPmaskMountGroups'] as $IPel) {
00156 if ($this->info['REMOTE_ADDR'] && $IPel[0] && t3lib_div::cmpIP($this->info['REMOTE_ADDR'],$IPel[0])) {$groups[]=intval($IPel[1]);}
00157 }
00158 }
00159 $groups = array_unique($groups);
00160
00161 if (count($groups)) {
00162 $list = implode(',',$groups);
00163
00164 if ($this->writeDevLog) t3lib_div::devLog('Get usergroups with id: '.$list, 'tx_sv_auth');
00165
00166 $lockToDomain_SQL = ' AND (lockToDomain="" OR lockToDomain="'.$this->info['HTTP_HOST'].'")';
00167 if (!$this->info['showHiddenRecords']) $hiddenP = 'AND NOT hidden ';
00168 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->db_groups['table'], 'NOT deleted '.$hiddenP.' AND uid IN ('.$list.')'.$lockToDomain_SQL);
00169 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00170 $groupDataArr[$row['uid']] = $row;
00171 }
00172 if ($res) $GLOBALS['TYPO3_DB']->sql_free_result($res);
00173
00174 } else {
00175 if ($this->writeDevLog) t3lib_div::devLog('No usergroups found.', 'tx_sv_auth', 2);
00176 }
00177
00178
00179 } elseif ($this->mode=='getGroupsBE') {
00180
00181 # Get the BE groups here
00182 # still needs to be implemented in t3lib_userauthgroup
00183 }
00184
00185 return $groupDataArr;
00186 }
00187 }
00188
00189
00190
00191 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/sv/class.tx_sv_auth.php']) {
00192 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/sv/class.tx_sv_auth.php']);
00193 }
00194 ?>