ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilAuthBase Class Reference

Base class for all PEAR and ILIAS auth classes. More...

+ Inheritance diagram for ilAuthBase:
+ Collaboration diagram for ilAuthBase:

Public Member Functions

 supportsRedirects ()
 Returns true, if the current auth mode allows redirects to e.g the login screen, public section ... More...
 
 getContainer ()
 Get container object. More...
 
 getExceededUserName ()
 

Protected Member Functions

 initAuth ()
 Init auth object Enable logging, set callbacks... More...
 
 loginObserver ($a_username, $a_auth)
 Called after successful login. More...
 
 failedLoginObserver ($a_username, $a_auth)
 Called after failed login. More...
 
 checkAuthObserver ($a_username, $a_auth)
 Called after each check auth request. More...
 
 logoutObserver ($a_username, $a_auth)
 Called after logout. More...
 

Protected Attributes

 $sub_status = null
 
 $exceeded_user_name
 

Detailed Description

Base class for all PEAR and ILIAS auth classes.

Enables logging, observers.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 33 of file class.ilAuthBase.php.

Member Function Documentation

◆ checkAuthObserver()

ilAuthBase::checkAuthObserver (   $a_username,
  $a_auth 
)
protected

Called after each check auth request.

Returns
Parameters
array$a_username
object$a_auth

Definition at line 245 of file class.ilAuthBase.php.

References getContainer().

246  {
247  #$GLOBALS['ilLog']->write(__METHOD__.': Check auth observer called');
248  return $this->getContainer()->checkAuthObserver($a_username,$a_auth);
249  }
getContainer()
Get container object.
+ Here is the call graph for this function:

◆ failedLoginObserver()

ilAuthBase::failedLoginObserver (   $a_username,
  $a_auth 
)
protected

Called after failed login.

Returns
Parameters
array$a_username
object$a_auth

Definition at line 208 of file class.ilAuthBase.php.

References $ilLog, $usr_id, ilSecuritySettings\_getInstance(), ilObjUser\_getLoginAttempts(), ilObjUser\_incrementLoginAttempts(), ilObjUser\_lookupId(), ilObjUser\_setUserInactive(), and getContainer().

209  {
210  global $ilLog;
211 
212  $ilLog->write(__METHOD__.': login failed for user '.$a_username.
213  ', remote:'.$_SERVER['REMOTE_ADDR'].':'.$_SERVER['REMOTE_PORT'].
214  ', server:'.$_SERVER['SERVER_ADDR'].':'.$_SERVER['SERVER_PORT']
215  );
216 
217  if($a_username)
218  {
219  $usr_id = ilObjUser::_lookupId($a_username);
220  if(!in_array($usr_id, array(ANONYMOUS_USER_ID, SYSTEM_USER_ID)))
221  {
223  $login_attempts = ilObjUser::_getLoginAttempts($usr_id);
224 
225  require_once 'Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
226  $security = ilSecuritySettings::_getInstance();
227  $max_attempts = $security->getLoginMaxAttempts();
228 
229  if((int)$max_attempts && $login_attempts >= $max_attempts)
230  {
232  }
233  }
234  }
235 
236  return $this->getContainer()->failedLoginObserver($a_username,$a_auth);
237  }
static _incrementLoginAttempts($a_usr_id)
static _lookupId($a_user_str)
lookup id by login
getContainer()
Get container object.
static _getLoginAttempts($a_usr_id)
static _setUserInactive($a_usr_id)
static _getInstance()
Get instance of ilSecuritySettings.
+ Here is the call graph for this function:

◆ getContainer()

ilAuthBase::getContainer ( )
final

Get container object.

Returns
object ilAuthContainerBase

Definition at line 55 of file class.ilAuthBase.php.

Referenced by checkAuthObserver(), failedLoginObserver(), loginObserver(), and logoutObserver().

56  {
57  return $this->storage;
58  }
+ Here is the caller graph for this function:

◆ getExceededUserName()

ilAuthBase::getExceededUserName ( )

Definition at line 268 of file class.ilAuthBase.php.

References $exceeded_user_name.

269  {
271  }

◆ initAuth()

ilAuthBase::initAuth ( )
finalprotected

Init auth object Enable logging, set callbacks...

Returns
void

Definition at line 65 of file class.ilAuthBase.php.

References $GLOBALS, AUTH_LOG_DEBUG, and ilSessionControl\initSession().

Referenced by ilAuthOpenId\__construct(), ilAuthCAS\__construct(), ilAuthSOAP\__construct(), ilAuthWeb\__construct(), ilAuthHTTP\__construct(), ilAuthCalendarToken\__construct(), ilAuthCron\__construct(), ilAuthApache\__construct(), and ilAuthECS\__construct().

66  {
68 
69  $this->enableLogging = false;
70  //$this->enableLogging = false;
71 
72  if ($this->enableLogging)
73  {
74  $GLOBALS['ilLog']->write(__METHOD__.': Init callbacks');
75  }
76  $this->setLoginCallback(array($this,'loginObserver'));
77  $this->setFailedLoginCallback(array($this,'failedLoginObserver'));
78  $this->setCheckAuthCallback(array($this,'checkAuthObserver'));
79  $this->setLogoutCallback(array($this,'logoutObserver'));
80 
81  include_once('Services/Authentication/classes/class.ilAuthLogObserver.php');
82  $this->attachLogObserver(new ilAuthLogObserver(AUTH_LOG_DEBUG));
83 
84  }
const AUTH_LOG_DEBUG
Auth Log level - DEBUG.
Definition: Auth.php:59
$GLOBALS['ct_recipient']
static initSession()
mark session with type regarding to the context.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loginObserver()

ilAuthBase::loginObserver (   $a_username,
  $a_auth 
)
protected

Called after successful login.

Returns
Parameters
array$a_username
object$a_auth

Definition at line 92 of file class.ilAuthBase.php.

References $ilLog, $ilSetting, ilSecuritySettings\_getInstance(), ilObjUser\_loginExists(), ilObjUser\_resetLoginAttempts(), AUTH_USER_INACTIVE, AUTH_USER_SIMULTANEOUS_LOGIN, AUTH_USER_TIME_LIMIT_EXCEEDED, AUTH_USER_WRONG_IP, ilAuthFactory\CONTEXT_ECS, getContainer(), ilAuthFactory\getContext(), ilSessionControl\handleLoginEvent(), ilObjUser\hasActiveSession(), and ilUserProfile\isProfileIncomplete().

93  {
94  global $ilLog, $ilAppEventHandler, $ilSetting;
95 
96  if($this->getContainer()->loginObserver($a_username,$a_auth))
97  {
98  // validate user
99  include_once "Services/User/classes/class.ilObjUser.php";
100  $user_id = ilObjUser::_loginExists($a_auth->getUsername());
101  if($user_id != ANONYMOUS_USER_ID)
102  {
103  $user = new ilObjUser($user_id);
104 
105  // check if profile is complete
106  include_once "Services/User/classes/class.ilUserProfile.php";
108  {
109  $user->setProfileIncomplete(true);
110  $user->update();
111  }
112 
113  // --- extended user validation
114  //
115  // we only have a single status, so abort after each one
116  // order from highest priority to lowest
117 
118  // active?
119  if(!$user->getActive())
120  {
121  $this->status = AUTH_USER_INACTIVE;
122  $a_auth->logout();
123  return;
124  }
125 
126  // time limit
127  if(!$user->checkTimeLimit())
128  {
129  $this->status = AUTH_USER_TIME_LIMIT_EXCEEDED;
130  // #16327
131  $this->exceeded_user_name = $this->getUserName();
132  $a_auth->logout();
133  return;
134  }
135 
136  // check client ip
137  $clientip = $user->getClientIP();
138  if (trim($clientip) != "")
139  {
140  $clientip = preg_replace("/[^0-9.?*,:]+/","",$clientip);
141  $clientip = str_replace(".","\\.",$clientip);
142  $clientip = str_replace(Array("?","*",","), Array("[0-9]","[0-9]*","|"), $clientip);
143  if (!preg_match("/^".$clientip."$/", $_SERVER["REMOTE_ADDR"]))
144  {
145  $this->status = AUTH_USER_WRONG_IP;
146  $a_auth->logout();
147  return;
148  }
149  }
150 
151  // simultaneous login
152  if($ilSetting->get('ps_prevent_simultaneous_logins') &&
153  ilObjUser::hasActiveSession($user_id))
154  {
155  $this->status = AUTH_USER_SIMULTANEOUS_LOGIN;
156  $a_auth->logout();
157  return;
158  }
159 
160  include_once 'Services/Tracking/classes/class.ilOnlineTracking.php';
161  ilOnlineTracking::addUser($user_id);
162 
163  include_once 'Modules/Forum/classes/class.ilObjForum.php';
164  ilObjForum::_updateOldAccess($user_id);
165 
166  require_once 'Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
167  $security_settings = ilSecuritySettings::_getInstance();
168 
169  // determine first login of user for setting an indicator
170  // which still is available in PersonalDesktop, Repository, ...
171  // (last login date is set to current date in next step)
172  if($security_settings->isPasswordChangeOnFirstLoginEnabled() &&
173  $user->getLastLogin() == null
174  )
175  {
176  $user->resetLastPasswordChange();
177  }
178 
179  $user->refreshLogin();
180 
181  // reset counter for failed logins
183  }
184 
185  // --- anonymous/registered user
186 
187  $ilLog->write(
188  __METHOD__ . ': logged in as ' . $a_auth->getUsername() .
189  ', remote:' . $_SERVER['REMOTE_ADDR'] . ':' . $_SERVER['REMOTE_PORT'] .
190  ', server:' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT']
191  );
192 
193  ilSessionControl::handleLoginEvent($a_auth->getUsername(), $a_auth);
194 
195  $ilAppEventHandler->raise(
196  'Services/Authentication', 'afterLogin',
197  array('username' => $a_auth->getUsername())
198  );
199  }
200  }
static isProfileIncomplete($a_user, $a_include_udf=true, $a_personal_data_only=true)
Check if all required personal data fields are set.
const AUTH_USER_INACTIVE
const AUTH_USER_WRONG_IP
getContainer()
Get container object.
const AUTH_USER_TIME_LIMIT_EXCEEDED
static _resetLoginAttempts($a_usr_id)
static _loginExists($a_login, $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...
static handleLoginEvent($a_login, $a_auth)
when current session is allowed to be created it marks it with type regarding to the sessions user co...
static hasActiveSession($a_user_id)
Check for simultaneous login.
loginObserver($a_username, $a_auth)
Called after successful login.
const AUTH_USER_SIMULTANEOUS_LOGIN
global $ilSetting
Definition: privfeed.php:40
static _getInstance()
Get instance of ilSecuritySettings.
+ Here is the call graph for this function:

◆ logoutObserver()

ilAuthBase::logoutObserver (   $a_username,
  $a_auth 
)
protected

Called after logout.

Returns
Parameters
array$a_username
object$a_auth

Definition at line 257 of file class.ilAuthBase.php.

References $ilLog, getContainer(), and ilSessionControl\handleLogoutEvent().

258  {
259  global $ilLog;
260 
261  $ilLog->write(__METHOD__.': Logout observer called');
262 
264 
265  return $this->getContainer()->logoutObserver($a_username,$a_auth);
266  }
getContainer()
Get container object.
static handleLogoutEvent()
reset sessions type to unknown
+ Here is the call graph for this function:

◆ supportsRedirects()

ilAuthBase::supportsRedirects ( )

Returns true, if the current auth mode allows redirects to e.g the login screen, public section ...

Returns

Definition at line 46 of file class.ilAuthBase.php.

47  {
48  return true;
49  }

Field Documentation

◆ $exceeded_user_name

ilAuthBase::$exceeded_user_name
protected

Definition at line 39 of file class.ilAuthBase.php.

Referenced by getExceededUserName().

◆ $sub_status

ilAuthBase::$sub_status = null
protected

Definition at line 37 of file class.ilAuthBase.php.


The documentation for this class was generated from the following file: