ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilAuthFrontend Class Reference
+ Inheritance diagram for ilAuthFrontend:
+ Collaboration diagram for ilAuthFrontend:

Public Member Functions

 __construct (ilAuthSession $session, ilAuthStatus $status, ilAuthCredentials $credentials, array $providers)
 
 getAuthSession ()
 Get auth session. More...
 
 getCredentials ()
 Get auth credentials. More...
 
 getProviders ()
 Get providers. More...
 
 getStatus ()
 
 resetStatus ()
 Reset status. 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 ()
 
 handleLoginAttempts ()
 

Private Attributes

ilLogger $logger
 
ilSetting $settings
 
ilLanguage $lng
 
ilAuthCredentials $credentials
 
ilAuthStatus $status
 
array $providers
 
ilAuthSession $auth_session
 
ilAppEventHandler $ilAppEventHandler
 
ilUserProfile $user_profile
 
bool $authenticated = false
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilAuthFrontend::__construct ( ilAuthSession  $session,
ilAuthStatus  $status,
ilAuthCredentials  $credentials,
array  $providers 
)
Parameters
ilAuthSession$session
ilAuthStatus$status
ilAuthCredentials$credentials
ilAuthProvider[]$providers

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

References $credentials, $DIC, $providers, $status, ILIAS\Repository\lng(), ILIAS\Repository\logger(), and ILIAS\Repository\settings().

55  {
56  global $DIC;
57  $this->logger = $DIC->logger()->auth();
58  $this->settings = $DIC->settings();
59  $this->lng = $DIC->language();
60  $this->ilAppEventHandler = $DIC->event();
61 
62  $this->auth_session = $session;
63  $this->credentials = $credentials;
64  $this->status = $status;
65  $this->providers = $providers;
66 
67  $this->user_profile = new ilUserProfile();
68  }
Global event handler.
Class ilUserProfile.
global $DIC
Definition: shib_login.php:25
ilAuthCredentials $credentials
+ Here is the call graph for this function:

Member Function Documentation

◆ authenticate()

ilAuthFrontend::authenticate ( )

Try to authenticate user.

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

References $provider, getProviders(), getStatus(), handleAccountMigration(), handleAuthenticationFail(), handleAuthenticationSuccess(), ILIAS\Repository\logger(), resetStatus(), ilAuthStatus\STATUS_ACCOUNT_MIGRATION_REQUIRED, ilAuthStatus\STATUS_AUTHENTICATED, and ilAuthStatus\STATUS_AUTHENTICATION_FAILED.

176  : bool
177  {
178  foreach ($this->getProviders() as $provider) {
179  $this->resetStatus();
180 
181  $this->logger->debug('Trying authentication against: ' . get_class($provider));
182 
183  $provider->doAuthentication($this->getStatus());
184 
185  $this->logger->debug('Authentication user id: ' . $this->getStatus()->getAuthenticatedUserId());
186 
187  switch ($this->getStatus()->getStatus()) {
189  return $this->handleAuthenticationSuccess($provider);
190 
192  $this->logger->notice("Account migration required.");
193  if ($provider instanceof ilAuthProviderAccountMigrationInterface) {
194  return $this->handleAccountMigration($provider);
195  }
196 
197  $this->logger->error('Authentication migratittion required but provider does not support interface' . get_class($provider));
198  break;
200  default:
201  $this->logger->debug('Authentication failed against: ' . get_class($provider));
202  break;
203  }
204  }
205  return $this->handleAuthenticationFail();
206  }
getProviders()
Get providers.
const STATUS_AUTHENTICATION_FAILED
handleAuthenticationSuccess(ilAuthProviderInterface $provider)
Handle successful authentication.
handleAccountMigration(ilAuthProviderAccountMigrationInterface $provider)
Handle account migration.
resetStatus()
Reset status.
$provider
Definition: ltitoken.php:80
const STATUS_ACCOUNT_MIGRATION_REQUIRED
+ Here is the call graph for this function:

◆ checkActivation()

ilAuthFrontend::checkActivation ( ilObjUser  $user)
protected

Check activation.

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

References ilObjUser\getActive().

Referenced by handleAuthenticationSuccess().

367  : bool
368  {
369  return $user->getActive();
370  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkExceededLoginAttempts()

ilAuthFrontend::checkExceededLoginAttempts ( ilObjUser  $user)
protected

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

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

Referenced by handleAuthenticationSuccess().

372  : bool
373  {
374  if ($user->getId() === ANONYMOUS_USER_ID) {
375  return true;
376  }
377 
378  $isInactive = !$user->getActive();
379  if (!$isInactive) {
380  return true;
381  }
382 
383  $security = ilSecuritySettings::_getInstance();
384  $maxLoginAttempts = $security->getLoginMaxAttempts();
385 
386  if (!$maxLoginAttempts) {
387  return true;
388  }
389 
390  $numLoginAttempts = \ilObjUser::_getLoginAttempts($user->getId());
391 
392  return $numLoginAttempts < $maxLoginAttempts;
393  }
static _getLoginAttempts(int $a_usr_id)
const ANONYMOUS_USER_ID
Definition: constants.php:27
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 406 of file class.ilAuthFrontend.php.

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

Referenced by handleAuthenticationSuccess().

406  : bool
407  {
408  $clientip = $user->getClientIP();
409  if (trim($clientip) !== "") {
410  $clientip = preg_replace("/[^0-9.?*,:]+/", "", $clientip);
411  $clientip = str_replace([".", "?", "*", ","], ["\\.", "[0-9]", "[0-9]*", "|"], $clientip);
412 
413  ilLoggerFactory::getLogger('auth')->debug('Check ip ' . $clientip . ' against ' . $_SERVER['REMOTE_ADDR']);
414 
415  if (!preg_match("/^" . $clientip . "$/", $_SERVER["REMOTE_ADDR"])) {
416  return false;
417  }
418  }
419  return true;
420  }
static getLogger(string $a_component_id)
Get component logger.
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
+ 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.

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

References getAuthSession(), ilObject\getId(), ilObjUser\hasActiveSession(), ILIAS\Repository\logger(), and ILIAS\Repository\settings().

Referenced by handleAuthenticationSuccess().

425  : bool
426  {
427  $this->logger->debug('Setting prevent simultaneous session is: ' . $this->settings->get('ps_prevent_simultaneous_logins'));
428  return !($this->settings->get('ps_prevent_simultaneous_logins') &&
429  ilObjUser::hasActiveSession($user->getId(), $this->getAuthSession()->getId()));
430  }
static hasActiveSession(int $a_user_id, string $a_session_id)
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.

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

References ilObjUser\checkTimeLimit().

Referenced by handleAuthenticationSuccess().

398  : bool
399  {
400  return $user->checkTimeLimit();
401  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAuthSession()

ilAuthFrontend::getAuthSession ( )

Get auth session.

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

References $auth_session.

Referenced by checkSimultaneousLogins(), and handleAuthenticationSuccess().

74  {
75  return $this->auth_session;
76  }
ilAuthSession $auth_session
+ Here is the caller graph for this function:

◆ getCredentials()

ilAuthFrontend::getCredentials ( )

Get auth credentials.

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

References $credentials.

Referenced by handleLoginAttempts(), and migrateAccount().

82  {
83  return $this->credentials;
84  }
Interface of auth credentials.
ilAuthCredentials $credentials
+ Here is the caller graph for this function:

◆ getProviders()

ilAuthFrontend::getProviders ( )

Get providers.

Returns
ilAuthProviderInterface[] $provider

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

References $providers.

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

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

◆ getStatus()

ilAuthFrontend::getStatus ( )
Returns

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

References $status.

Referenced by ilAuthFrontendHTTP\authenticate(), authenticate(), handleAccountMigration(), handleAuthenticationSuccess(), handleLoginAttempts(), migrateAccount(), migrateAccountNew(), and resetStatus().

98  : ilAuthStatus
99  {
100  return $this->status;
101  }
+ Here is the caller graph for this function:

◆ handleAccountMigration()

ilAuthFrontend::handleAccountMigration ( ilAuthProviderAccountMigrationInterface  $provider)
protected

Handle account migration.

Parameters
ilAuthProvider$provider

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

References ANONYMOUS_USER_ID, ilLogLevel\DEBUG, ilSession\dumpToString(), ilAuthProviderAccountMigrationInterface\getExternalAccountName(), getStatus(), ilAuthProviderAccountMigrationInterface\getTriggerAuthMode(), ilAuthProviderAccountMigrationInterface\getUserAuthModeName(), ILIAS\Repository\logger(), and ilSession\set().

Referenced by authenticate().

212  : bool
213  {
214  $this->logger->debug('Trigger auth mode: ' . $provider->getTriggerAuthMode());
215  $this->logger->debug('Desired auth mode: ' . $provider->getUserAuthModeName());
216  $this->logger->debug('External account: ' . $provider->getExternalAccountName());
217 
218  $this->getStatus()->setAuthenticatedUserId(ANONYMOUS_USER_ID);
219  #$this->getStatus()->setStatus(ilAuthStatus::STATUS_AUTHENTICATED);
220 
221  ilSession::set(static::MIG_TRIGGER_AUTHMODE, $provider->getTriggerAuthMode());
222  ilSession::set(static::MIG_DESIRED_AUTHMODE, $provider->getUserAuthModeName());
223  ilSession::set(static::MIG_EXTERNAL_ACCOUNT, $provider->getExternalAccountName());
224 
226 
227  return true;
228  }
static dumpToString()
const ANONYMOUS_USER_ID
Definition: constants.php:27
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.
static set(string $a_var, $a_val)
Set a value.
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

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

References handleLoginAttempts(), and ILIAS\Repository\logger().

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

432  : bool
433  {
434  $this->logger->debug('Authentication failed for all authentication methods.');
435 
436  $this->handleLoginAttempts();
437 
438  return false;
439  }
+ 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.

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

References $_SERVER, ilSecuritySettings\_getInstance(), ilObjUser\_lookupLogin(), ilOnlineTracking\addUser(), ANONYMOUS_USER_ID, checkActivation(), checkExceededLoginAttempts(), checkIp(), checkSimultaneousLogins(), checkTimeLimit(), ilAuthFactory\CONTEXT_ECS, ilContext\CONTEXT_LTI_PROVIDER, getAuthSession(), ilAuthFactory\getContext(), ilObjectFactory\getInstanceByObjId(), ilLoggerFactory\getLogger(), getStatus(), ilContext\getType(), ilSessionControl\handleLoginEvent(), ilInitialisation\initUserAccount(), ILIAS\Repository\logger(), ilAppEventHandler\raise(), ilSession\set(), ILIAS\Repository\settings(), ilAuthStatus\STATUS_AUTHENTICATION_FAILED, and ilAuthStatus\STATUS_CODE_ACTIVATION_REQUIRED.

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

233  : bool
234  {
235  $user = ilObjectFactory::getInstanceByObjId($this->getStatus()->getAuthenticatedUserId(), false);
236 
237  $this->getStatus()->setReason('auth_err_invalid_user_account');
238  // reset expired status
239  $this->getAuthSession()->setExpired(false);
240 
241  if (!$user instanceof ilObjUser) {
242  $this->logger->error('Cannot instantiate user account with id: ' . $this->getStatus()->getAuthenticatedUserId());
244  $this->getStatus()->setAuthenticatedUserId(ANONYMOUS_USER_ID);
245  return false;
246  }
247 
248  if (!$this->checkExceededLoginAttempts($user)) {
249  $this->logger->info('Authentication failed for inactive user with id and too may login attempts: ' . $this->getStatus()->getAuthenticatedUserId());
251  $this->getStatus()->setAuthenticatedUserId(ANONYMOUS_USER_ID);
252  return false;
253  }
254 
255  if (!$this->checkActivation($user)) {
256  $this->logger->info('Authentication failed for inactive user with id: ' . $this->getStatus()->getAuthenticatedUserId());
258  $this->getStatus()->setAuthenticatedUserId(ANONYMOUS_USER_ID);
259  return false;
260  }
261 
262  // time limit
263  if (!$this->checkTimeLimit($user)) {
264  $this->logger->info('Authentication failed (time limit restriction) for user with id: ' . $this->getStatus()->getAuthenticatedUserId());
265 
266  if ($this->settings->get('user_reactivate_code')) {
267  $this->logger->debug('Accout reactivation codes are active');
269  } else {
270  $this->logger->debug('Accout reactivation codes are inactive');
272  $this->getStatus()->setAuthenticatedUserId(ANONYMOUS_USER_ID);
273  }
274  return false;
275  }
276 
277  // ip check
278  if (!$this->checkIp($user)) {
279  $this->logger->info('Authentication failed (wrong ip) for user with id: ' . $this->getStatus()->getAuthenticatedUserId());
281  $this->getStatus()->setAuthenticatedUserId(ANONYMOUS_USER_ID);
282  return false;
283  }
284 
285  // check simultaneos logins
286  $this->logger->debug('Check simutaneous login');
287  if (!$this->checkSimultaneousLogins($user)) {
288  $this->logger->info('Authentication failed: simultaneous logins forbidden for user: ' . $this->getStatus()->getAuthenticatedUserId());
290  $this->getStatus()->setAuthenticatedUserId(ANONYMOUS_USER_ID);
291  return false;
292  }
293 
294  // check if profile is complete
295  if (
296  $this->user_profile->isProfileIncomplete($user) &&
299  ) {
300  ilLoggerFactory::getLogger('auth')->info('User profile is incomplete.');
301  $user->setProfileIncomplete(true);
302  $user->update();
303  }
304 
305  // redirects in case of error (session pool limit reached)
306  ilSessionControl::handleLoginEvent($user->getLogin(), $this->getAuthSession());
307 
308 
309  // @todo move to event handling
310  ilOnlineTracking::addUser($user->getId());
311 
312  $security_settings = ilSecuritySettings::_getInstance();
313 
314  // determine first login of user for setting an indicator
315  // which still is available in PersonalDesktop, Repository, ...
316  // (last login date is set to current date in next step)
317  if (
318  $security_settings->isPasswordChangeOnFirstLoginEnabled() &&
319  $user->getLastLogin() === ''
320  ) {
321  $user->resetLastPasswordChange();
322  }
323  $user->refreshLogin();
324 
325  if ($user->getLoginAttempts() > 0) {
326  $user->setLoginAttempts(0);
327  $user->update();
328  }
329 
330 
331  $this->logger->info('Successfully authenticated: ' . ilObjUser::_lookupLogin($this->getStatus()->getAuthenticatedUserId()));
332  $this->getAuthSession()->setAuthenticated(true, $this->getStatus()->getAuthenticatedUserId());
333 
335 
336  ilSession::set('orig_request_target', '');
337 
338 
339  // --- anonymous/registered user
340  if (PHP_SAPI !== "cli") {
341  $this->logger->info(
342  'logged in as ' . $user->getLogin() .
343  ', remote:' . $_SERVER['REMOTE_ADDR'] . ':' . $_SERVER['REMOTE_PORT'] .
344  ', server:' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT']
345  );
346  } else {
347  $this->logger->info(
348  'logged in as ' . $user->getLogin() . ' from CLI'
349  );
350  }
351 
352  // finally raise event
353  $this->ilAppEventHandler->raise(
354  'components/ILIAS/Authentication',
355  'afterLogin',
356  array(
357  'username' => $user->getLogin())
358  );
359 
360  $this->getStatus()->setReason('');
361  return true;
362  }
Global event handler.
checkIp(ilObjUser $user)
Check ip.
const ANONYMOUS_USER_ID
Definition: constants.php:27
static getLogger(string $a_component_id)
Get component logger.
const STATUS_AUTHENTICATION_FAILED
checkSimultaneousLogins(ilObjUser $user)
Check simultaneous logins.
const CONTEXT_LTI_PROVIDER
checkExceededLoginAttempts(ilObjUser $user)
static addUser(int $a_user_id)
checkTimeLimit(ilObjUser $user)
Check time limit.
checkActivation(ilObjUser $user)
Check activation.
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
const CONTEXT_ECS
Calendar authentication with auth token.
static handleLoginEvent(string $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 getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
const STATUS_CODE_ACTIVATION_REQUIRED
static getType()
Get context type.
static initUserAccount()
Init user with current account id.
getAuthSession()
Get auth session.
static _getInstance()
Get instance of ilSecuritySettings.
static set(string $a_var, $a_val)
Set a value.
raise(string $a_component, string $a_event, array $a_parameter=[])
Raise an event.
static _lookupLogin(int $a_user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleLoginAttempts()

ilAuthFrontend::handleLoginAttempts ( )
protected

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

References ilObjUser\_checkExternalAuthAccount(), ilAuthUtils\_getAuthModeName(), ilAuthModeDetermination\_getInstance(), ilSecuritySettings\_getInstance(), ilObjUser\_getLoginAttempts(), ilObjUser\_incrementLoginAttempts(), ilObjUser\_lookupId(), ilObjUser\_setUserInactive(), ANONYMOUS_USER_ID, ilAuthUtils\AUTH_LOCAL, getCredentials(), getStatus(), and ILIAS\Repository\logger().

Referenced by handleAuthenticationFail().

441  : void
442  {
443  $security = ilSecuritySettings::_getInstance();
444  $max_attempts = $security->getLoginMaxAttempts();
445  if ($max_attempts < 1) {
446  return;
447  }
448 
449  $auth_determination = ilAuthModeDetermination::_getInstance();
450  if ($this->getCredentials()->getAuthMode() !== '') {
451  $auth_modes = [
452  $this->getCredentials()->getAuthMode()
453  ];
454  } else {
455  $auth_modes = $auth_determination->getAuthModeSequence($this->getCredentials()->getUsername());
456  }
457 
458  $usr_id_candidates = [];
459  foreach (array_filter($auth_modes) as $auth_mode) {
460  if ((int) $auth_mode === ilAuthUtils::AUTH_LOCAL) {
461  $usr_id_candidates[] = ilObjUser::_lookupId($this->getCredentials()->getUsername());
462  continue;
463  }
464 
466  ilAuthUtils::_getAuthModeName($auth_mode),
467  $this->getCredentials()->getUsername(),
468  false
469  );
470  if (!is_string($login) || $login === '') {
471  continue;
472  }
473 
474  $usr_id_candidates[] = ilObjUser::_lookupId($login);
475  }
476 
477  $usr_id_candidates = array_values(array_unique(array_filter($usr_id_candidates, intval(...))));
478  $num_deacticated_accounts = 0;
479  foreach ($usr_id_candidates as $usr_id) {
480  if ($usr_id === ANONYMOUS_USER_ID) {
481  continue;
482  }
483 
484  $num_login_attempts = ilObjUser::_getLoginAttempts($usr_id);
485 
486  if ($num_login_attempts <= $max_attempts) {
488  $this->logger->notice(
489  sprintf(
490  'Incremented login attempts for user %s with id %s.',
491  $this->getCredentials()->getUsername(),
492  $usr_id
493  )
494  );
495  }
496 
497  if ($num_login_attempts >= $max_attempts) {
499 
500  ++$num_deacticated_accounts;
501  $this->logger->warning(
502  sprintf(
503  'User account %s with id %s set to inactive due to exceeded login attempts.',
504  $this->getCredentials()->getUsername(),
505  $usr_id
506  )
507  );
508  }
509  }
510 
511  if ($num_deacticated_accounts > 0) {
512  $this->getStatus()->setReason('auth_err_login_attempts_deactivation');
513  }
514  }
static _getLoginAttempts(int $a_usr_id)
const ANONYMOUS_USER_ID
Definition: constants.php:27
static _lookupId($a_user_str)
static _checkExternalAuthAccount(string $a_auth, string $a_account, bool $tryFallback=true)
check whether external account and authentication method matches with a user
static _getAuthModeName($a_auth_key)
getCredentials()
Get auth credentials.
static _setUserInactive(int $a_usr_id)
static _incrementLoginAttempts(int $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:

◆ migrateAccount()

ilAuthFrontend::migrateAccount ( ilAuthSession  $session)

Migrate Account to existing user account.

Exceptions

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

References $provider, ilSession\get(), getCredentials(), ilObjectFactory\getInstanceByObjId(), getProviders(), getStatus(), ilAuthSession\getUserId(), handleAuthenticationFail(), handleAuthenticationSuccess(), ilAuthSession\isAuthenticated(), ILIAS\Repository\logger(), and ilAuthStatus\STATUS_AUTHENTICATED.

117  : bool
118  {
119  if (!$session->isAuthenticated()) {
120  $this->logger->warning('Desired user account is not authenticated');
121  return false;
122  }
123  $user = ilObjectFactory::getInstanceByObjId($session->getUserId(), false);
124 
125  if (!$user instanceof ilObjUser) {
126  $this->logger->info('Cannot instantiate user account for account migration: ' . $session->getUserId());
127  return false;
128  }
129 
130  $user->setAuthMode(ilSession::get(static::MIG_DESIRED_AUTHMODE));
131 
132  $this->logger->debug('new auth mode is: ' . ilSession::get(self::MIG_DESIRED_AUTHMODE));
133 
134  $user->setExternalAccount(ilSession::get(static::MIG_EXTERNAL_ACCOUNT));
135  $user->update();
136 
137  foreach ($this->getProviders() as $provider) {
138  if (!$provider instanceof ilAuthProviderAccountMigrationInterface) {
139  $this->logger->warning('Provider: ' . get_class($provider) . ' does not support account migration.');
140  throw new InvalidArgumentException('Invalid auth provider given.');
141  }
142  $this->getCredentials()->setUsername(ilSession::get(static::MIG_EXTERNAL_ACCOUNT));
143  $provider->migrateAccount($this->getStatus());
145  return $this->handleAuthenticationSuccess($provider);
146  }
147  }
148  return $this->handleAuthenticationFail();
149  }
static get(string $a_var)
getProviders()
Get providers.
handleAuthenticationSuccess(ilAuthProviderInterface $provider)
Handle successful authentication.
isAuthenticated()
Check if session is authenticated.
getCredentials()
Get auth credentials.
getUserId()
Get authenticated user id.
$provider
Definition: ltitoken.php:80
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:

◆ migrateAccountNew()

ilAuthFrontend::migrateAccountNew ( )

Create new user account.

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

References $provider, getStatus(), handleAuthenticationFail(), handleAuthenticationSuccess(), ILIAS\Repository\logger(), and ilAuthStatus\STATUS_AUTHENTICATED.

154  : bool
155  {
156  foreach ($this->providers as $provider) {
157  if (!$provider instanceof ilAuthProviderAccountMigrationInterface) {
158  $this->logger->warning('Provider: ' . get_class($provider) . ' does not support account migration.');
159  throw new InvalidArgumentException('Invalid auth provider given.');
160  }
161  $provider->createNewAccount($this->getStatus());
162 
163  if ($provider instanceof ilAuthProviderInterface &&
165  return $this->handleAuthenticationSuccess($provider);
166  }
167  }
168  return $this->handleAuthenticationFail();
169  }
handleAuthenticationSuccess(ilAuthProviderInterface $provider)
Handle successful authentication.
$provider
Definition: ltitoken.php:80
Standard interface for auth provider implementations.
+ Here is the call graph for this function:

◆ resetStatus()

ilAuthFrontend::resetStatus ( )

Reset status.

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

References ANONYMOUS_USER_ID, getStatus(), and ilAuthStatus\STATUS_UNDEFINED.

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

106  : void
107  {
108  $this->getStatus()->setStatus(ilAuthStatus::STATUS_UNDEFINED);
109  $this->getStatus()->setReason('');
110  $this->getStatus()->setAuthenticatedUserId(ANONYMOUS_USER_ID);
111  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $auth_session

ilAuthSession ilAuthFrontend::$auth_session
private

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

Referenced by getAuthSession().

◆ $authenticated

bool ilAuthFrontend::$authenticated = false
private

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

◆ $credentials

ilAuthCredentials ilAuthFrontend::$credentials
private

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

Referenced by __construct(), and getCredentials().

◆ $ilAppEventHandler

ilAppEventHandler ilAuthFrontend::$ilAppEventHandler
private

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

◆ $lng

ilLanguage ilAuthFrontend::$lng
private

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

◆ $logger

ilLogger ilAuthFrontend::$logger
private

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

◆ $providers

array ilAuthFrontend::$providers
private

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

Referenced by __construct(), and getProviders().

◆ $settings

ilSetting ilAuthFrontend::$settings
private

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

◆ $status

ilAuthStatus ilAuthFrontend::$status
private

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

Referenced by __construct(), and getStatus().

◆ $user_profile

ilUserProfile ilAuthFrontend::$user_profile
private

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

◆ MIG_DESIRED_AUTHMODE

const ilAuthFrontend::MIG_DESIRED_AUTHMODE = 'mig_desired_auth_mode'

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

◆ MIG_EXTERNAL_ACCOUNT

const ilAuthFrontend::MIG_EXTERNAL_ACCOUNT = 'mig_ext_account'

Definition at line 29 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: