19 declare(strict_types=1);
57 $this->
logger = $DIC->logger()->auth();
59 $this->
lng = $DIC->language();
62 $this->auth_session = $session;
120 $this->
logger->warning(
'Desired user account is not authenticated');
126 $this->
logger->info(
'Cannot instantiate user account for account migration: ' . $session->
getUserId());
134 $user->setExternalAccount(
ilSession::get(static::MIG_EXTERNAL_ACCOUNT));
139 $this->
logger->warning(
'Provider: ' . get_class($provider) .
' does not support account migration.');
143 $provider->migrateAccount($this->
getStatus());
156 foreach ($this->providers as
$provider) {
158 $this->
logger->warning(
'Provider: ' . get_class($provider) .
' does not support account migration.');
161 $provider->createNewAccount($this->
getStatus());
181 $this->
logger->debug(
'Trying authentication against: ' . get_class($provider));
183 $provider->doAuthentication($this->
getStatus());
185 $this->
logger->debug(
'Authentication user id: ' . $this->
getStatus()->getAuthenticatedUserId());
192 $this->
logger->notice(
"Account migration required.");
197 $this->
logger->error(
'Authentication migratittion required but provider does not support interface' . get_class($provider));
201 $this->
logger->debug(
'Authentication failed against: ' . get_class($provider));
219 #$this->getStatus()->setStatus(ilAuthStatus::STATUS_AUTHENTICATED); 237 $this->
getStatus()->setReason(
'auth_err_invalid_user_account');
242 $this->
logger->error(
'Cannot instantiate user account with id: ' . $this->
getStatus()->getAuthenticatedUserId());
249 $this->
logger->info(
'Authentication failed for inactive user with id and too may login attempts: ' . $this->
getStatus()->getAuthenticatedUserId());
256 $this->
logger->info(
'Authentication failed for inactive user with id: ' . $this->
getStatus()->getAuthenticatedUserId());
264 $this->
logger->info(
'Authentication failed (time limit restriction) for user with id: ' . $this->
getStatus()->getAuthenticatedUserId());
266 if ($this->
settings->get(
'user_reactivate_code')) {
267 $this->
logger->debug(
'Accout reactivation codes are active');
270 $this->
logger->debug(
'Accout reactivation codes are inactive');
279 $this->
logger->info(
'Authentication failed (wrong ip) for user with id: ' . $this->
getStatus()->getAuthenticatedUserId());
286 $this->
logger->debug(
'Check simutaneous login');
288 $this->
logger->info(
'Authentication failed: simultaneous logins forbidden for user: ' . $this->
getStatus()->getAuthenticatedUserId());
296 $this->user_profile->isProfileIncomplete($user) &&
301 $user->setProfileIncomplete(
true);
318 $security_settings->isPasswordChangeOnFirstLoginEnabled() &&
319 $user->getLastLogin() ===
'' 321 $user->resetLastPasswordChange();
323 $user->refreshLogin();
325 if ($user->getLoginAttempts() > 0) {
326 $user->setLoginAttempts(0);
340 if (PHP_SAPI !==
"cli") {
342 'logged in as ' . $user->getLogin() .
348 'logged in as ' . $user->getLogin() .
' from CLI' 354 'Services/Authentication',
357 'username' => $user->getLogin())
384 $maxLoginAttempts = $security->getLoginMaxAttempts();
386 if (!$maxLoginAttempts) {
392 return $numLoginAttempts < $maxLoginAttempts;
409 if (trim($clientip) !==
"") {
410 $clientip = preg_replace(
"/[^0-9.?*,:]+/",
"", $clientip);
411 $clientip = str_replace([
".",
"?",
"*",
","], [
"\\.",
"[0-9]",
"[0-9]*",
"|"], $clientip);
415 if (!preg_match(
"/^" . $clientip .
"$/", $_SERVER[
"REMOTE_ADDR"])) {
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') &&
437 $this->
logger->debug(
'Authentication failed for all authentication methods.');
447 $max_attempts = $security->getLoginMaxAttempts();
448 if ($max_attempts < 1) {
459 if ($num_login_attempts <= $max_attempts) {
463 if ($num_login_attempts >= $max_attempts) {
468 'User account %s with id %s set to inactive due to exceeded login attempts.',
static hasActiveSession(int $a_user_id, string $a_session_id)
migrateAccount(ilAuthSession $session)
Migrate Account to existing user account.
static get(string $a_var)
static _getLoginAttempts(int $a_usr_id)
getProviders()
Get providers.
checkIp(ilObjUser $user)
Check ip.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getLogger(string $a_component_id)
Get component logger.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const STATUS_AUTHENTICATION_FAILED
handleAuthenticationSuccess(ilAuthProviderInterface $provider)
Handle successful authentication.
checkSimultaneousLogins(ilObjUser $user)
Check simultaneous logins.
const CONTEXT_LTI_PROVIDER
isAuthenticated()
Check if session is authenticated.
static _lookupId($a_user_str)
handleAccountMigration(ilAuthProviderAccountMigrationInterface $provider)
Handle account migration.
resetStatus()
Reset status.
checkExceededLoginAttempts(ilObjUser $user)
getCredentials()
Get auth credentials.
migrateAccountNew()
Create new user account.
ilAuthSession $auth_session
getUserId()
Get authenticated user id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
authenticate()
Try to authenticate user.
static addUser(int $a_user_id)
checkTimeLimit(ilObjUser $user)
Check time limit.
handleAuthenticationFail()
Handle failed authenication.
checkActivation(ilObjUser $user)
Check activation.
static _setUserInactive(int $a_usr_id)
getTriggerAuthMode()
Get auth mode which triggered the account migration 2_1 for ldap account migration with server id 1 1...
ilUserProfile $user_profile
const CONTEXT_ECS
Calendar authentication with auth token.
ilAuthCredentials $credentials
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_AUTHENTICATED
const MIG_EXTERNAL_ACCOUNT
ilAppEventHandler $ilAppEventHandler
const STATUS_CODE_ACTIVATION_REQUIRED
static _incrementLoginAttempts(int $a_usr_id)
__construct(ilAuthSession $session, ilAuthStatus $status, ilAuthCredentials $credentials, array $providers)
static getType()
Get context type.
static initUserAccount()
Init user with current account id.
const MIG_DESIRED_AUTHMODE
getAuthSession()
Get auth session.
getExternalAccountName()
Get external account name.
const MIG_TRIGGER_AUTHMODE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getInstance()
Get instance of ilSecuritySettings.
const STATUS_ACCOUNT_MIGRATION_REQUIRED
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...
raise(string $a_component, string $a_event, array $a_parameter=[])
Raise an event.
static _lookupLogin(int $a_user_id)