ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilAuthFrontend Class Reference

Description of class class. More...

+ Inheritance diagram for ilAuthFrontend:
+ Collaboration diagram for ilAuthFrontend:

Public Member Functions

 __construct (ilAuthSession $session, ilAuthStatus $status, ilAuthCredentials $credentials, array $providers)
 Constructor. More...
 
 getAuthSession ()
 Get auth session. More...
 
 getCredentials ()
 Get auth credentials. More...
 
 getProviders ()
 Get providers. More...
 
 getStatus ()
 
 resetStatus ()
 Reset status. More...
 
 getLogger ()
 Get logger. More...
 
 migrateAccount (ilAuthSession $session)
 Migrate Account to existing user account. More...
 
 migrateAccountNew ()
 Create new user account. More...
 
 authenticate ()
 Try to authenticate user. More...
 

Data Fields

const MIG_EXTERNAL_ACCOUNT = 'mig_ext_account'
 
const MIG_TRIGGER_AUTHMODE = 'mig_trigger_auth_mode'
 
const MIG_DESIRED_AUTHMODE = 'mig_desired_auth_mode'
 

Protected Member Functions

 handleAccountMigration (ilAuthProviderAccountMigrationInterface $provider)
 Handle account migration. More...
 
 handleAuthenticationSuccess (ilAuthProviderInterface $provider)
 Handle successful authentication. More...
 
 checkActivation (ilObjUser $user)
 Check activation. More...
 
 checkExceededLoginAttempts (\ilObjUser $user)
 
 checkTimeLimit (ilObjUser $user)
 Check time limit. More...
 
 checkIp (ilObjUser $user)
 Check ip. More...
 
 checkSimultaneousLogins (ilObjUser $user)
 Check simultaneous logins. More...
 
 handleAuthenticationFail ()
 Handle failed authenication. More...
 

Private Attributes

 $logger = null
 
 $credentials = null
 
 $status = null
 
 $providers = array()
 
 $auth_session = null
 
 $authenticated = false
 

Detailed Description

Description of class class.

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

Definition at line 11 of file class.ilAuthFrontend.php.

Constructor & Destructor Documentation

◆ __construct()

ilAuthFrontend::__construct ( ilAuthSession  $session,
ilAuthStatus  $status,
ilAuthCredentials  $credentials,
array  $providers 
)

Constructor.

Parameters
ilAuthSession$session
ilAuthCredentials$credentials

Definition at line 30 of file class.ilAuthFrontend.php.

References $credentials, $providers, $session, $status, and ilLoggerFactory\getLogger().

31  {
32  $this->logger = ilLoggerFactory::getLogger('auth');
33 
34  $this->auth_session = $session;
35  $this->credentials = $credentials;
36  $this->status = $status;
37  $this->providers = $providers;
38  }
$session
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

Member Function Documentation

◆ authenticate()

ilAuthFrontend::authenticate ( )

Try to authenticate user.

Definition at line 166 of file class.ilAuthFrontend.php.

References League\OAuth2\Client\Provider\$provider, getLogger(), getProviders(), getStatus(), handleAccountMigration(), handleAuthenticationFail(), handleAuthenticationSuccess(), resetStatus(), ilAuthStatus\STATUS_ACCOUNT_MIGRATION_REQUIRED, ilAuthStatus\STATUS_AUTHENTICATED, and ilAuthStatus\STATUS_AUTHENTICATION_FAILED.

167  {
168  foreach ($this->getProviders() as $provider) {
169  $this->resetStatus();
170 
171  $this->getLogger()->debug('Trying authentication against: ' . get_class($provider));
172 
173  $provider->doAuthentication($this->getStatus());
174 
175  $this->getLogger()->debug('Authentication user id: ' . $this->getStatus()->getAuthenticatedUserId());
176 
177  switch ($this->getStatus()->getStatus()) {
179  return $this->handleAuthenticationSuccess($provider);
180 
182  $this->getLogger()->notice("Account migration required.");
183  return $this->handleAccountMigration($provider);
184 
186  default:
187  $this->getLogger()->debug('Authentication failed against: ' . get_class($provider));
188  break;
189  }
190  }
191  return $this->handleAuthenticationFail();
192  }
getProviders()
Get providers.
const STATUS_AUTHENTICATION_FAILED
handleAuthenticationSuccess(ilAuthProviderInterface $provider)
Handle successful authentication.
handleAccountMigration(ilAuthProviderAccountMigrationInterface $provider)
Handle account migration.
resetStatus()
Reset status.
getLogger()
Get logger.
handleAuthenticationFail()
Handle failed authenication.
const STATUS_ACCOUNT_MIGRATION_REQUIRED
+ Here is the call graph for this function:

◆ checkActivation()

ilAuthFrontend::checkActivation ( ilObjUser  $user)
protected

Check activation.

Parameters
ilObjUser$user

Definition at line 370 of file class.ilAuthFrontend.php.

References ilObjUser\getActive().

Referenced by handleAuthenticationSuccess().

371  {
372  return $user->getActive();
373  }
getActive()
get user active state public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkExceededLoginAttempts()

ilAuthFrontend::checkExceededLoginAttempts ( \ilObjUser  $user)
protected
Parameters
\ilObjUser$user
Returns
bool

Definition at line 379 of file class.ilAuthFrontend.php.

References ilSecuritySettings\_getInstance(), ilObjUser\_getLoginAttempts(), array, ilObjUser\getActive(), and ilObject\getId().

Referenced by handleAuthenticationSuccess().

380  {
381  if (in_array($user->getId(), array(ANONYMOUS_USER_ID))) {
382  return true;
383  }
384 
385  $isInactive = !$user->getActive();
386  if (!$isInactive) {
387  return true;
388  }
389 
390  require_once 'Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
391  $security = ilSecuritySettings::_getInstance();
392  $maxLoginAttempts = $security->getLoginMaxAttempts();
393 
394  if (!(int) $maxLoginAttempts) {
395  return true;
396  }
397 
398  $numLoginAttempts = \ilObjUser::_getLoginAttempts($user->getId());
399 
400  return $numLoginAttempts < $maxLoginAttempts;
401  }
static _getLoginAttempts($a_usr_id)
Create styles array
The data for the language used.
static _getInstance()
Get instance of ilSecuritySettings.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkIp()

ilAuthFrontend::checkIp ( ilObjUser  $user)
protected

Check ip.

Definition at line 416 of file class.ilAuthFrontend.php.

References $_SERVER, array, ilObjUser\getClientIP(), and ilLoggerFactory\getLogger().

Referenced by handleAuthenticationSuccess().

417  {
418  $clientip = $user->getClientIP();
419  if (trim($clientip) != "") {
420  $clientip = preg_replace("/[^0-9.?*,:]+/", "", $clientip);
421  $clientip = str_replace(".", "\\.", $clientip);
422  $clientip = str_replace(array("?","*",","), array("[0-9]","[0-9]*","|"), $clientip);
423 
424  ilLoggerFactory::getLogger('auth')->debug('Check ip ' . $clientip . ' against ' . $_SERVER['REMOTE_ADDR']);
425 
426  if (!preg_match("/^" . $clientip . "$/", $_SERVER["REMOTE_ADDR"])) {
427  return false;
428  }
429  }
430  return true;
431  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
Create styles array
The data for the language used.
static getLogger($a_component_id)
Get component logger.
getClientIP()
get client ip number public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkSimultaneousLogins()

ilAuthFrontend::checkSimultaneousLogins ( ilObjUser  $user)
protected

Check simultaneous logins.

Parameters
ilObjUser$user

Definition at line 437 of file class.ilAuthFrontend.php.

References $GLOBALS, getAuthSession(), ilObject\getId(), getLogger(), and ilObjUser\hasActiveSession().

Referenced by handleAuthenticationSuccess().

438  {
439  $this->getLogger()->debug('Setting prevent simultaneous session is: ' . (string) $GLOBALS['ilSetting']->get('ps_prevent_simultaneous_logins'));
440  if (
441  $GLOBALS['ilSetting']->get('ps_prevent_simultaneous_logins') &&
442  ilObjUser::hasActiveSession($user->getId(), $this->getAuthSession()->getId())
443  ) {
444  return false;
445  }
446  return true;
447  }
static hasActiveSession($a_user_id, $a_session_id)
Check for simultaneous login.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
getLogger()
Get logger.
getId()
get object id public
getAuthSession()
Get auth session.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkTimeLimit()

ilAuthFrontend::checkTimeLimit ( ilObjUser  $user)
protected

Check time limit.

Parameters
ilObjUser$user
Returns
type

Definition at line 408 of file class.ilAuthFrontend.php.

References ilObjUser\checkTimeLimit().

Referenced by handleAuthenticationSuccess().

409  {
410  return $user->checkTimeLimit();
411  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAuthSession()

ilAuthFrontend::getAuthSession ( )

Get auth session.

Returns
ilAuthSession

Definition at line 44 of file class.ilAuthFrontend.php.

References $auth_session.

Referenced by checkSimultaneousLogins(), and handleAuthenticationSuccess().

45  {
46  return $this->auth_session;
47  }
+ Here is the caller graph for this function:

◆ getCredentials()

ilAuthFrontend::getCredentials ( )

Get auth credentials.

Returns
ilAuthCredentials

Definition at line 53 of file class.ilAuthFrontend.php.

References $credentials.

Referenced by handleAuthenticationFail(), and migrateAccount().

54  {
55  return $this->credentials;
56  }
+ Here is the caller graph for this function:

◆ getLogger()

ilAuthFrontend::getLogger ( )

Get logger.

Returns
ilLogger

Definition at line 89 of file class.ilAuthFrontend.php.

References $logger.

Referenced by ilAuthFrontendHTTP\authenticate(), authenticate(), checkSimultaneousLogins(), handleAccountMigration(), handleAuthenticationFail(), handleAuthenticationSuccess(), and migrateAccount().

90  {
91  return $this->logger;
92  }
+ Here is the caller graph for this function:

◆ getProviders()

ilAuthFrontend::getProviders ( )

Get providers.

Returns
ilAuthProviderInterface[] $provider

Definition at line 62 of file class.ilAuthFrontend.php.

References $providers.

Referenced by ilAuthFrontendHTTP\authenticate(), authenticate(), and migrateAccount().

63  {
64  return $this->providers;
65  }
+ Here is the caller graph for this function:

◆ getStatus()

ilAuthFrontend::getStatus ( )

◆ handleAccountMigration()

ilAuthFrontend::handleAccountMigration ( ilAuthProviderAccountMigrationInterface  $provider)
protected

Handle account migration.

Parameters
ilAuthProvider$provider

Definition at line 198 of file class.ilAuthFrontend.php.

References $_SESSION, ilLogLevel\DEBUG, ilAuthProviderAccountMigrationInterface\getExternalAccountName(), getLogger(), getStatus(), ilAuthProviderAccountMigrationInterface\getTriggerAuthMode(), ilAuthProviderAccountMigrationInterface\getUserAuthModeName(), and ilSession\set().

Referenced by authenticate().

199  {
200  $this->getLogger()->debug('Trigger auth mode: ' . $provider->getTriggerAuthMode());
201  $this->getLogger()->debug('Desired auth mode: ' . $provider->getUserAuthModeName());
202  $this->getLogger()->debug('External account: ' . $provider->getExternalAccountName());
203 
204  $this->getStatus()->setAuthenticatedUserId(ANONYMOUS_USER_ID);
205  #$this->getStatus()->setStatus(ilAuthStatus::STATUS_AUTHENTICATED);
206 
207  ilSession::set(static::MIG_TRIGGER_AUTHMODE, $provider->getTriggerAuthMode());
208  ilSession::set(static::MIG_DESIRED_AUTHMODE, $provider->getUserAuthModeName());
209  ilSession::set(static::MIG_EXTERNAL_ACCOUNT, $provider->getExternalAccountName());
210 
211  $this->getLogger()->dump($_SESSION, ilLogLevel::DEBUG);
212 
213  return true;
214  }
$_SESSION["AccountId"]
static set($a_var, $a_val)
Set a value.
getLogger()
Get logger.
getTriggerAuthMode()
Get auth mode which triggered the account migration 2_1 for ldap account migration with server id 1 1...
getExternalAccountName()
Get external account name.
getUserAuthModeName()
Get user auth mode name ldap_1 for ldap account migration with server id 1 apache for apache auth...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleAuthenticationFail()

ilAuthFrontend::handleAuthenticationFail ( )
protected

Handle failed authenication.

Definition at line 452 of file class.ilAuthFrontend.php.

References ilSecuritySettings\_getInstance(), ilObjUser\_getLoginAttempts(), ilObjUser\_incrementLoginAttempts(), ilObjUser\_lookupId(), ilObjUser\_setUserInactive(), array, getCredentials(), getLogger(), and getStatus().

Referenced by authenticate(), migrateAccount(), and migrateAccountNew().

453  {
454  $this->getLogger()->debug('Authentication failed for all authentication methods.');
455 
456  $user_id = ilObjUser::_lookupId($this->getCredentials()->getUsername());
457  if (!in_array($user_id, array(ANONYMOUS_USER_ID))) {
459  $login_attempts = ilObjUser::_getLoginAttempts($user_id);
460 
461  $this->getLogger()->notice('Increased login attempts for user: ' . $this->getCredentials()->getUsername());
462 
463  include_once './Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
464  $security = ilSecuritySettings::_getInstance();
465  $max_attempts = $security->getLoginMaxAttempts();
466 
467  if ((int) $max_attempts && $login_attempts >= $max_attempts) {
468  $this->getStatus()->setReason('auth_err_login_attempts_deactivation');
469  $this->getLogger()->warning('User account set to inactive due to exceeded login attempts.');
470  ilObjUser::_setUserInactive($user_id);
471  }
472  }
473  }
static _incrementLoginAttempts($a_usr_id)
static _lookupId($a_user_str)
Lookup id by login.
getCredentials()
Get auth credentials.
static _getLoginAttempts($a_usr_id)
getLogger()
Get logger.
Create styles array
The data for the language used.
static _setUserInactive($a_usr_id)
static _getInstance()
Get instance of ilSecuritySettings.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleAuthenticationSuccess()

ilAuthFrontend::handleAuthenticationSuccess ( ilAuthProviderInterface  $provider)
protected

Handle successful authentication.

Parameters
ilAuthProviderInterface$provider

Definition at line 220 of file class.ilAuthFrontend.php.

References $_SERVER, $factory, $GLOBALS, ilSecuritySettings\_getInstance(), ilObjUser\_lookupLogin(), ilObjUser\_resetLoginAttempts(), ilObjForum\_updateOldAccess(), array, checkActivation(), checkExceededLoginAttempts(), checkIp(), checkSimultaneousLogins(), checkTimeLimit(), ilAuthFactory\CONTEXT_ECS, ilContext\CONTEXT_LTI_PROVIDER, getAuthSession(), ilAuthFactory\getContext(), ilLoggerFactory\getLogger(), getLogger(), getStatus(), ilContext\getType(), ilSessionControl\handleLoginEvent(), ilUserProfile\isProfileIncomplete(), ilSession\set(), ilAuthStatus\STATUS_AUTHENTICATION_FAILED, and ilAuthStatus\STATUS_CODE_ACTIVATION_REQUIRED.

Referenced by ilAuthFrontendHTTP\authenticate(), authenticate(), migrateAccount(), and migrateAccountNew().

221  {
222  include_once './Services/Object/classes/class.ilObjectFactory.php';
223  $factory = new ilObjectFactory();
224  $user = $factory->getInstanceByObjId($this->getStatus()->getAuthenticatedUserId(), false);
225 
226  // reset expired status
227  $this->getAuthSession()->setExpired(false);
228 
229  if (!$user instanceof ilObjUser) {
230  $this->getLogger()->error('Cannot instantiate user account with id: ' . $this->getStatus()->getAuthenticatedUserId());
232  $this->getStatus()->setAuthenticatedUserId(0);
233  $this->getStatus()->setReason('auth_err_invalid_user_account');
234  return false;
235  }
236 
237  if (!$this->checkExceededLoginAttempts($user)) {
238  $this->getLogger()->info('Authentication failed for inactive user with id and too may login attempts: ' . $this->getStatus()->getAuthenticatedUserId());
240  $this->getStatus()->setAuthenticatedUserId(0);
241  $this->getStatus()->setReason('err_inactive_login_attempts');
242  return false;
243  }
244 
245  if (!$this->checkActivation($user)) {
246  $this->getLogger()->info('Authentication failed for inactive user with id: ' . $this->getStatus()->getAuthenticatedUserId());
248  $this->getStatus()->setAuthenticatedUserId(0);
249  $this->getStatus()->setReason('err_inactive');
250  return false;
251  }
252 
253  // time limit
254  if (!$this->checkTimeLimit($user)) {
255  $this->getLogger()->info('Authentication failed (time limit restriction) for user with id: ' . $this->getStatus()->getAuthenticatedUserId());
256 
257  if ($GLOBALS['ilSetting']->get('user_reactivate_code')) {
258  $this->getLogger()->debug('Accout reactivation codes are active');
260  } else {
261  $this->getLogger()->debug('Accout reactivation codes are inactive');
263  $this->getStatus()->setAuthenticatedUserId(0);
264  }
265  $this->getStatus()->setReason('time_limit_reached');
266  return false;
267  }
268 
269  // ip check
270  if (!$this->checkIp($user)) {
271  $this->getLogger()->info('Authentication failed (wrong ip) for user with id: ' . $this->getStatus()->getAuthenticatedUserId());
273  $this->getStatus()->setAuthenticatedUserId(0);
274 
275  $this->getStatus()->setTranslatedReason(
276  sprintf(
277  $GLOBALS['DIC']->language()->txt('wrong_ip_detected'),
278  $_SERVER['REMOTE_ADDR']
279  )
280  );
281  return false;
282  }
283 
284  // check simultaneos logins
285  $this->getLogger()->debug('Check simutaneous login');
286  if (!$this->checkSimultaneousLogins($user)) {
287  $this->getLogger()->info('Authentication failed: simultaneous logins forbidden for user: ' . $this->getStatus()->getAuthenticatedUserId());
289  $this->getStatus()->setAuthenticatedUserId(0);
290  $this->getStatus()->setReason('simultaneous_login_detected');
291  return false;
292  }
293 
294  // check if profile is complete
295  include_once "Services/User/classes/class.ilUserProfile.php";
296  include_once './Services/Context/classes/class.ilContext.php';
297  if (
301  ) {
302  ilLoggerFactory::getLogger('auth')->info('User profile is incomplete.');
303  $user->setProfileIncomplete(true);
304  $user->update();
305  }
306 
307  // redirects in case of error (session pool limit reached)
308  ilSessionControl::handleLoginEvent($user->getLogin(), $this->getAuthSession());
309 
310 
311  // @todo move to event handling
312  include_once 'Services/Tracking/classes/class.ilOnlineTracking.php';
313  ilOnlineTracking::addUser($user->getId());
314 
315  // @todo move to event handling
316  include_once 'Modules/Forum/classes/class.ilObjForum.php';
317  ilObjForum::_updateOldAccess($user->getId());
318 
319  require_once 'Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
320  $security_settings = ilSecuritySettings::_getInstance();
321 
322  // determine first login of user for setting an indicator
323  // which still is available in PersonalDesktop, Repository, ...
324  // (last login date is set to current date in next step)
325  if (
326  $security_settings->isPasswordChangeOnFirstLoginEnabled() &&
327  $user->getLastLogin() == null
328  ) {
329  $user->resetLastPasswordChange();
330  }
331  $user->refreshLogin();
332 
333  // reset counter for failed logins
334  ilObjUser::_resetLoginAttempts($user->getId());
335 
336 
337  $this->getLogger()->info('Successfully authenticated: ' . ilObjUser::_lookupLogin($this->getStatus()->getAuthenticatedUserId()));
338  $this->getAuthSession()->setAuthenticated(true, $this->getStatus()->getAuthenticatedUserId());
339 
340  include_once './Services/Init/classes/class.ilInitialisation.php';
341  ilInitialisation::initUserAccount();
342 
343  ilSession::set('orig_request_target', '');
344  $user->hasToAcceptTermsOfServiceInSession(true);
345 
346 
347  // --- anonymous/registered user
348  $this->getLogger()->info(
349  'logged in as ' . $user->getLogin() .
350  ', remote:' . $_SERVER['REMOTE_ADDR'] . ':' . $_SERVER['REMOTE_PORT'] .
351  ', server:' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT']
352  );
353 
354  // finally raise event
355  global $ilAppEventHandler;
356  $ilAppEventHandler->raise(
357  'Services/Authentication',
358  'afterLogin',
359  array(
360  'username' => $user->getLogin())
361  );
362 
363  return true;
364  }
static _lookupLogin($a_user_id)
lookup login
static isProfileIncomplete($a_user, $a_include_udf=true, $a_personal_data_only=true)
Check if all required personal data fields are set.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
Class ilObjectFactory.
checkIp(ilObjUser $user)
Check ip.
checkExceededLoginAttempts(\ilObjUser $user)
const STATUS_AUTHENTICATION_FAILED
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$factory
Definition: metadata.php:47
checkSimultaneousLogins(ilObjUser $user)
Check simultaneous logins.
static set($a_var, $a_val)
Set a value.
const CONTEXT_LTI_PROVIDER
static _resetLoginAttempts($a_usr_id)
getLogger()
Get logger.
checkTimeLimit(ilObjUser $user)
Check time limit.
checkActivation(ilObjUser $user)
Check activation.
static _updateOldAccess($a_usr_id)
Create styles array
The data for the language used.
const STATUS_CODE_ACTIVATION_REQUIRED
static getLogger($a_component_id)
Get component logger.
static getType()
Get context type.
getAuthSession()
Get auth session.
static handleLoginEvent($a_login, ilAuthSession $auth_session)
when current session is allowed to be created it marks it with type regarding to the sessions user co...
static _getInstance()
Get instance of ilSecuritySettings.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ migrateAccount()

ilAuthFrontend::migrateAccount ( ilAuthSession  $session)

Migrate Account to existing user account.

Parameters
ilAuthSession$session
type$a_username
type$a_auth_mode
type$a_desired_authmode
Exceptions

Definition at line 102 of file class.ilAuthFrontend.php.

References League\OAuth2\Client\Provider\$provider, ilSession\get(), getCredentials(), getLogger(), getProviders(), getStatus(), ilAuthSession\getUserId(), handleAuthenticationFail(), handleAuthenticationSuccess(), ilAuthSession\isAuthenticated(), and ilAuthStatus\STATUS_AUTHENTICATED.

103  {
104  if (!$session->isAuthenticated()) {
105  $this->getLogger()->warning('Desired user account is not authenticated');
106  return false;
107  }
108  include_once './Services/Object/classes/class.ilObjectFactory.php';
109  $user_factory = new ilObjectFactory();
110  $user = $user_factory->getInstanceByObjId($session->getUserId(), false);
111 
112  if (!$user instanceof ilObjUser) {
113  $this->getLogger()->info('Cannot instantiate user account for account migration: ' . $session->getUserId());
114  return false;
115  }
116 
117  $user->setAuthMode(ilSession::get(static::MIG_DESIRED_AUTHMODE));
118 
119  $this->getLogger()->debug('new auth mode is: ' . ilSession::get(self::MIG_DESIRED_AUTHMODE));
120 
121  $user->setExternalAccount(ilSession::get(static::MIG_EXTERNAL_ACCOUNT));
122  $user->update();
123 
124  foreach ($this->getProviders() as $provider) {
125  if (!$provider instanceof ilAuthProviderAccountMigrationInterface) {
126  $this->logger->warning('Provider: ' . get_class($provider) . ' does not support account migration.');
127  throw new InvalidArgumentException('Invalid auth provider given.');
128  }
129  $this->getCredentials()->setUsername(ilSession::get(static::MIG_EXTERNAL_ACCOUNT));
130  $provider->migrateAccount($this->getStatus());
131  switch ($this->getStatus()->getStatus()) {
133  return $this->handleAuthenticationSuccess($provider);
134 
135  }
136  }
137  return $this->handleAuthenticationFail();
138  }
Class ilObjectFactory.
getProviders()
Get providers.
handleAuthenticationSuccess(ilAuthProviderInterface $provider)
Handle successful authentication.
static get($a_var)
Get a value.
isAuthenticated()
Check if session is authenticated.
getCredentials()
Get auth credentials.
getLogger()
Get logger.
getUserId()
Get authenticated user id.
handleAuthenticationFail()
Handle failed authenication.
+ Here is the call graph for this function:

◆ migrateAccountNew()

ilAuthFrontend::migrateAccountNew ( )

Create new user account.

Definition at line 143 of file class.ilAuthFrontend.php.

References League\OAuth2\Client\Provider\$provider, getStatus(), handleAuthenticationFail(), handleAuthenticationSuccess(), and ilAuthStatus\STATUS_AUTHENTICATED.

144  {
145  foreach ($this->providers as $provider) {
146  if (!$provider instanceof ilAuthProviderAccountMigrationInterface) {
147  $this->logger->warning('Provider: ' . get_class($provider) . ' does not support account migration.');
148  throw new InvalidArgumentException('Invalid auth provider given.');
149  }
150  $provider->createNewAccount($this->getStatus());
151 
152  switch ($this->getStatus()->getStatus()) {
154  return $this->handleAuthenticationSuccess($provider);
155 
156  }
157  }
158  return $this->handleAuthenticationFail();
159  }
handleAuthenticationSuccess(ilAuthProviderInterface $provider)
Handle successful authentication.
handleAuthenticationFail()
Handle failed authenication.
+ Here is the call graph for this function:

◆ resetStatus()

ilAuthFrontend::resetStatus ( )

Reset status.

Definition at line 78 of file class.ilAuthFrontend.php.

References getStatus(), and ilAuthStatus\STATUS_UNDEFINED.

Referenced by ilAuthFrontendHTTP\authenticate(), and authenticate().

79  {
80  $this->getStatus()->setStatus(ilAuthStatus::STATUS_UNDEFINED);
81  $this->getStatus()->setReason('');
82  $this->getStatus()->setAuthenticatedUserId(0);
83  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $auth_session

ilAuthFrontend::$auth_session = null
private

Definition at line 21 of file class.ilAuthFrontend.php.

Referenced by getAuthSession().

◆ $authenticated

ilAuthFrontend::$authenticated = false
private

Definition at line 23 of file class.ilAuthFrontend.php.

◆ $credentials

ilAuthFrontend::$credentials = null
private

Definition at line 18 of file class.ilAuthFrontend.php.

Referenced by __construct(), and getCredentials().

◆ $logger

ilAuthFrontend::$logger = null
private

Definition at line 17 of file class.ilAuthFrontend.php.

Referenced by getLogger().

◆ $providers

ilAuthFrontend::$providers = array()
private

Definition at line 20 of file class.ilAuthFrontend.php.

Referenced by __construct(), and getProviders().

◆ $status

ilAuthFrontend::$status = null
private

Definition at line 19 of file class.ilAuthFrontend.php.

Referenced by __construct(), and getStatus().

◆ MIG_DESIRED_AUTHMODE

const ilAuthFrontend::MIG_DESIRED_AUTHMODE = 'mig_desired_auth_mode'

Definition at line 15 of file class.ilAuthFrontend.php.

◆ MIG_EXTERNAL_ACCOUNT

const ilAuthFrontend::MIG_EXTERNAL_ACCOUNT = 'mig_ext_account'

Definition at line 13 of file class.ilAuthFrontend.php.

Referenced by ilStartUpGUI\doMigrationNewAccount().

◆ MIG_TRIGGER_AUTHMODE

const ilAuthFrontend::MIG_TRIGGER_AUTHMODE = 'mig_trigger_auth_mode'

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