19 declare(strict_types=1);
75 $this->
user = $user ?? $DIC->user();
76 $this->
mainTemplate = $mainTemplate ?? $DIC->ui()->mainTemplate();
77 $this->httpRequest = $httpRequest ?? $DIC->http()->request();
78 $this->
ctrl = $DIC->ctrl();
79 $this->
lng = $DIC->language();
80 $this->
lng->loadLanguageModule(
'auth');
82 $this->authSession = $DIC[
'ilAuthSession'];
83 $this->eventHandler = $DIC->event();
84 $this->setting = $DIC->settings();
85 $this->
access = $DIC->access();
86 $this->
help = $DIC->help();
87 $this->
http = $DIC->http();
89 $this->ui_factory = $DIC->ui()->factory();
90 $this->ui_renderer = $DIC->ui()->renderer();
92 $this->
ctrl->saveParameter($this, [
'rep_ref_id',
'lang',
'target',
'client_id']);
93 $this->
user->setLanguage($this->
lng->getLangKey());
94 $this->
help->setScreenIdComponent(
'init');
99 self::$forced_cmd = $cmd;
104 if (self::$forced_cmd) {
105 $cmd = self::$forced_cmd;
106 self::$forced_cmd =
'';
114 return $this->
refinery->custom()->transformation(
static function (array $values): array {
115 return array_merge(...$values);
121 return $this->
refinery->custom()->transformation(
static function (array $values): array {
122 $processed_values = array_merge(
124 isset($values[self::PROP_PASSWORD]) ? [self::PROP_PASSWORD => $values[self::PROP_PASSWORD]] : []
127 return $processed_values;
133 return $this->
http->wrapper()->query()->retrieve(
135 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->
refinery->always(
'')])
149 'doStandardAuthentication',
157 $next_class = $this->
ctrl->getNextClass($this) ??
'';
159 switch (strtolower($next_class)) {
160 case strtolower(ilLoginPageGUI::class):
163 case strtolower(ilAccountRegistrationGUI::class):
167 case strtolower(ilPasswordAssistanceGUI::class):
171 case strtolower(ilAccessibilityControlConceptGUI::class):
176 if (method_exists($this, $cmd)) {
195 $this->
ctrl->redirectByClass(ilAccountRegistrationGUI::class);
200 $this->
ctrl->saveParameterByClass(ilPasswordAssistanceGUI::class,
'key');
201 $this->
ctrl->redirectByClass(ilPasswordAssistanceGUI::class);
214 if ($this->authSession->isValid() && $this->authSession->getUserId() > 0 && !$this->
user->isAnonymous()) {
218 $is_forced_login = $this->
http->wrapper()->query()->retrieve(
221 $this->refinery->kindlyTo()->string(),
223 $this->
http->wrapper()->post()->retrieve(
226 $this->refinery->kindlyTo()->string(),
234 if ($is_forced_login) {
236 $this->
logger->debug(
'Force login');
238 if ($this->authSession->isValid()) {
240 $this->
logger->debug(
'Valid session -> logout current user');
242 $this->authSession->logout();
244 $this->eventHandler->raise(
245 'components/ILIAS/Authentication',
248 'username' => $this->
user->getLogin(),
249 'is_explicit_logout' =>
false,
253 $this->dic->user()->setId($this->authSession->getUserId());
254 $this->dic->user()->read();
257 $this->
logger->debug(
'Show login page');
258 foreach (
$messages as $type => $content) {
259 $this->
mainTemplate->setOnScreenMessage($type, $content);
266 if ($this->authSession->isValid()) {
267 $this->
logger->debug(
'Valid session -> redirect to starting page');
272 $this->
logger->debug(
'No valid session -> show login');
280 $this->
help->setSubScreenId(
'login');
282 $this->
getLogger()->debug(
'Showing login page');
284 $extUid = $this->
http->wrapper()->query()->retrieve(
286 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->
refinery->always(
'')])
289 $soapPw = $this->
http->wrapper()->query()->retrieve(
291 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->
refinery->always(
'')])
300 $credentials->setUsername($extUid);
301 $credentials->setPassword($soapPw);
302 $credentials->tryAuthenticationOnLoginPage();
305 $frontend->tryAuthenticationOnLoginPage();
307 $tpl = self::initStartUpTemplate(
'tpl.login.html');
314 $page_editor_html = $this->
showLoginForm($page_editor_html, $form);
322 if ($this->authSession->isExpired() || $this->
http->wrapper()->query()->has(
'session_expired')) {
323 $this->
mainTemplate->setOnScreenMessage(
'failure', $this->
lng->txt(
'auth_err_expired'));
324 } elseif ($this->
http->wrapper()->query()->has(
'reg_confirmation_msg')) {
325 $this->
lng->loadLanguageModule(
'registration');
326 $message_key = $this->
http->wrapper()->query()->retrieve(
327 'reg_confirmation_msg',
328 $this->
refinery->kindlyTo()->string()
330 $message_type = $message_key ===
'reg_account_confirmation_successful' ?
334 $this->
lng->txt($message_key)
338 if ($page_editor_html !==
'') {
339 $tpl->setVariable(
'LPE', $page_editor_html);
342 if ($this->authSession->isExpired()) {
345 $this->dic->user()->setId($this->authSession->getUserId());
346 $this->dic->user()->read();
350 self::printToGlobalTemplate($tpl);
360 $gtpl->setContent($tpl->get());
361 $gtpl->printToStdout(
'DEFAULT',
false,
true);
377 foreach ($message_types as $message_type) {
387 ?
string $username =
null,
390 $this->
help->setSubScreenId(
'code_input');
392 $this->
mainTemplate->setOnScreenMessage(
'failure', $this->
lng->txt(
'time_limit_reached'));
394 $tpl = self::initStartUpTemplate(
'tpl.login_reactivate_code.html');
395 $tpl->setVariable(
'FORM', $this->ui_renderer->render($form ?? $this->buildCodeForm($username)));
396 self::printToGlobalTemplate($tpl);
401 $this->
lng->loadLanguageModule(
'auth');
403 $field_factory = $this->ui_factory->input()->field();
405 $username_field = $field_factory
407 ->withRequired(
true);
408 if ($username !==
null) {
409 $username_field = $username_field->withValue($username);
412 return $this->ui_factory
417 $this->
ctrl->getFormAction($this,
'processCode'),
419 $field_factory->section(
421 self::PROP_CODE => $field_factory
423 $this->
lng->txt(
'auth_account_code'),
424 $this->
lng->txt(
'auth_account_code_info')
426 ->withRequired(
true),
428 self::PROP_USERNAME => $username_field,
430 $this->
lng->txt(
'auth_account_code_title'),
434 ->withSubmitLabel($this->
lng->txt(
'send'))
444 if ($this->
http->request()->getMethod() ===
'POST') {
445 $form = $form->withRequest($this->
http->request());
446 $form_data = $form->getData();
447 $form_valid = $form_data !==
null;
452 $code = $form_data[self::PROP_CODE];
453 $uname = $form_data[self::PROP_USERNAME];
460 $invalid_code =
false;
462 if ($valid_until ===
'0') {
465 if (is_numeric($valid_until)) {
466 $valid_until = strtotime(
'+' . $valid_until .
'days');
468 $valid_until = explode(
'-', $valid_until);
469 $valid_until = mktime(
473 (
int) $valid_until[1],
474 (
int) $valid_until[2],
475 (
int) $valid_until[0]
477 if ($valid_until < time()) {
478 $invalid_code =
true;
482 if (!$invalid_code) {
488 if (!$invalid_code) {
498 $this->
ctrl->setParameter($this,
'cu', 1);
499 $this->
lng->loadLanguageModule(
'auth');
505 $this->
ctrl->redirect($this,
'showLoginPage');
509 $this->
lng->loadLanguageModule(
'user');
510 $this->
mainTemplate->setOnScreenMessage(
'failure', $this->
lng->txt(
'user_account_code_not_valid'));
512 $this->
mainTemplate->setOnScreenMessage(
'failure', $this->
lng->txt(
'form_input_not_valid'));
520 $field_factory = $this->ui_factory->input()->field();
525 $auth_mode = $field_factory->radio($this->
lng->txt(
'auth_selection'))->withRequired(
true);
526 $visible_auth_methods = [];
528 if (isset($option[
'hide_in_ui']) && $option[
'hide_in_ui']) {
532 $auth_mode = $auth_mode->withOption((
string) $key, $option[
'txt']);
534 if (isset($option[
'checked'])) {
535 $auth_mode = $auth_mode->withValue($key);
537 $visible_auth_methods[] = $key;
540 if (count($visible_auth_methods) === 1) {
541 $auth_mode = $field_factory->hidden()->withRequired(
true)->withValue(current($visible_auth_methods));
544 $fields[self::PROP_AUTH_MODE] = $auth_mode;
548 self::PROP_USERNAME => $field_factory
549 ->text($this->
lng->txt(
'username'))
552 $this->
refinery->custom()->constraint(
553 static function (
string $value):
bool {
554 return $value !==
'';
556 static function (
Closure $lng,
string $value):
string {
557 return $lng(
'auth_required_username');
561 self::PROP_PASSWORD => $field_factory
562 ->password($this->
lng->txt(
'password'))
563 ->withRevelation(
true)
566 $this->
refinery->custom()->constraint(
567 static function (
string $value):
bool {
568 return $value !==
'';
570 static function (
Closure $lng,
string $value):
string {
571 return $lng(
'auth_required_password');
575 ->withAdditionalTransformation(
576 $this->
refinery->custom()->transformation(
577 static function (
ILIAS\
Data\Password $value):
string {
578 return $value->toString();
584 $sections = [$field_factory->section($fields, $this->
lng->txt(
'login_to_ilias_via_login_form'))];
586 return $this->ui_factory
590 ->standard($this->
ctrl->getFormAction($this,
'doStandardAuthentication'), $sections)
591 ->withDedicatedName(
'login_form')
592 ->withSubmitLabel($this->
lng->txt(
'log_in'))
599 $this->
getLogger()->debug(
'Trying lti authentication');
602 $credentials->initFromRequest();
611 $frontend = $frontend_factory->getFrontend(
617 $frontend->authenticate();
619 switch ($status->getStatus()) {
626 $this->
ctrl->redirect($this,
'showAccountMigration');
630 $this->
mainTemplate->setOnScreenMessage(
'failure', $this->
lng->txt($status->getReason()),
true);
631 $this->
ctrl->redirect($this,
'showLoginPage');
634 $this->
mainTemplate->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_wrong_login'));
640 $this->
getLogger()->debug(
'Trying apache authentication');
643 $credentials->initFromRequest();
650 $frontend_factory = new \ilAuthFrontendFactory();
652 $frontend = $frontend_factory->getFrontend(
658 $frontend->authenticate();
660 switch ($status->getStatus()) {
662 if ($credentials->hasValidTargetUrl()) {
665 'Authentication successful. Redirecting to starting page: %s',
666 $credentials->getTargetUrl()
669 $this->
ctrl->redirectToURL($credentials->getTargetUrl());
672 'Authentication successful, but no valid target URL given. Redirecting to default starting page.' 678 $this->
ctrl->redirect($this,
'showAccountMigration');
682 $this->
mainTemplate->setOnScreenMessage(
'failure', $status->getTranslatedReason(),
true);
683 $this->
ctrl->redirectToURL(
685 $this->
ctrl->getLinkTarget($this,
'showLoginPage',
'',
false,
false),
691 $this->
mainTemplate->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_wrong_login'));
700 if ($this->
http->request()->getMethod() ===
'POST') {
701 $form = $form->withRequest($this->
http->request());
702 $form_data = $form->getData();
703 $form_valid = $form_data !==
null;
711 $this->
getLogger()->debug(
'Trying to authenticate user.');
713 $auth_callback =
function () use ($form_data) {
715 $credentials->setUsername($form_data[self::PROP_USERNAME]);
716 $credentials->setPassword($form_data[self::PROP_PASSWORD]);
720 $credentials->setAuthMode($form_data[self::PROP_AUTH_MODE]);
724 $providers = $provider_factory->getProviders($credentials);
730 $frontend = $frontend_factory->getFrontend(
736 $frontend->authenticate();
741 if (($auth_duration = $this->setting->get(
'auth_duration')) !==
null) {
742 $duration = $this->
http->durations()->callbackDuration((
int) $auth_duration);
743 $status =
$duration->stretch($auth_callback);
745 $status = $auth_callback();
748 switch ($status->getStatus()) {
751 'Authentication successful; Redirecting to starting page.' 762 $this->
ctrl->redirect($this,
'showAccountMigration');
766 $this->
mainTemplate->setOnScreenMessage(
'failure', $status->getTranslatedReason());
772 string $page_editor_html,
780 $this->ui_renderer->render($form ?? $this->buildStandardLoginForm()),
788 if ($page_editor_html !==
'') {
789 return $page_editor_html;
792 return $page_editor_html;
799 if ($this->setting->get(
'shib_active')) {
800 $tpl =
new ilTemplate(
'tpl.login_form_shibboleth.html',
true,
true,
'components/ILIAS/Init');
806 $federation_name = $this->setting->get(
'shib_federation_name');
807 $admin_mail =
' <a href="mailto:' . $this->setting->get(
'admin_email') .
'">ILIAS ' . $this->
lng->txt(
810 if ($this->setting->get(
'shib_hos_type') ===
'external_wayf') {
811 $tpl->setCurrentBlock(
'shibboleth_login');
812 $tpl->setVariable(
'TXT_SHIB_LOGIN', $this->
lng->txt(
'login_to_ilias_via_shibboleth'));
813 $tpl->setVariable(
'IL_TARGET', $target);
814 $tpl->setVariable(
'TXT_SHIB_FEDERATION_NAME', $this->setting->get(
'shib_federation_name'));
815 $tpl->setVariable(
'TXT_SHIB_LOGIN_BUTTON', $this->setting->get(
'shib_login_button'));
817 'TXT_SHIB_LOGIN_INSTRUCTIONS',
819 $this->
lng->txt(
'shib_general_login_instructions'),
824 $tpl->setVariable(
'TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS', $this->setting->get(
'shib_login_instructions'));
825 $tpl->parseCurrentBlock();
826 } elseif ($this->setting->get(
'shib_hos_type') ==
'embedded_wayf') {
827 $tpl->setCurrentBlock(
'shibboleth_custom_login');
828 $customInstructions = stripslashes($this->setting->get(
'shib_login_instructions'));
829 $tpl->setVariable(
'TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS', $customInstructions);
830 $tpl->parseCurrentBlock();
832 $tpl->setCurrentBlock(
'shibboleth_wayf_login');
833 $tpl->setVariable(
'TXT_SHIB_LOGIN', $this->
lng->txt(
'login_to_ilias_via_shibboleth'));
834 $tpl->setVariable(
'TXT_SHIB_FEDERATION_NAME', $this->setting->get(
'shib_federation_name'));
836 'TXT_SELECT_HOME_ORGANIZATION',
838 $this->
lng->txt(
'shib_select_home_organization'),
839 $this->setting->get(
'shib_federation_name')
842 $tpl->setVariable(
'TXT_CONTINUE', $this->
lng->txt(
'btn_next'));
843 $tpl->setVariable(
'TXT_SHIB_HOME_ORGANIZATION', $this->
lng->txt(
'shib_home_organization'));
845 'TXT_SHIB_LOGIN_INSTRUCTIONS',
847 $this->
lng->txt(
'shib_general_wayf_login_instructions'),
851 $tpl->setVariable(
'TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS', $this->setting->get(
'shib_login_instructions'));
855 $tpl->setVariable(
'TXT_SHIB_INVALID_SELECTION', $ilShibbolethWAYF->showNotice());
856 $tpl->setVariable(
'SHIB_IDP_LIST', $ilShibbolethWAYF->generateSelection());
857 $tpl->setVariable(
'ILW_TARGET', $target);
858 $tpl->parseCurrentBlock();
865 '[list-shibboleth-login-form]',
870 return $page_editor_html;
878 string $page_editor_html,
879 string $element_html,
881 string $fallback_tplvar
883 if ($page_editor_html ===
'') {
884 $tpl->setVariable($fallback_tplvar, $element_html);
885 return $page_editor_html;
888 if (stripos($page_editor_html, $placeholder) ===
false) {
889 $tpl->setVariable($fallback_tplvar, $element_html);
890 return $page_editor_html;
893 return str_replace($placeholder, $element_html, $page_editor_html);
900 $ipe_language = $ipe_settings->getIliasEditorLanguage($this->
lng->getLangKey());
901 if (!$ipe_language) {
914 $page_gui->setStyleId(0);
916 $page_gui->setPresentationTitle(
'');
917 $page_gui->setTemplateOutput(
false);
918 $page_gui->setHeader(
'');
920 return $page_gui->showPage();
927 $rtpl =
new ilTemplate(
'tpl.login_registration_links.html',
true,
true,
'components/ILIAS/Init');
931 $rtpl->setCurrentBlock(
'new_registration');
932 $rtpl->setVariable(
'REGISTER', $this->
lng->txt(
'registration'));
935 $this->
ctrl->getLinkTargetByClass(ilAccountRegistrationGUI::class)
937 $rtpl->parseCurrentBlock();
940 if ($this->setting->get(
'password_assistance')) {
941 $rtpl->setCurrentBlock(
'password_assistance');
942 $rtpl->setVariable(
'FORGOT_PASSWORD', $this->
lng->txt(
'forgot_password'));
943 $rtpl->setVariable(
'FORGOT_USERNAME', $this->
lng->txt(
'forgot_username'));
945 'CMD_FORGOT_PASSWORD',
946 $this->
ctrl->getLinkTargetByClass(ilPasswordAssistanceGUI::class)
949 'CMD_FORGOT_USERNAME',
950 $this->
ctrl->getLinkTargetByClass(ilPasswordAssistanceGUI::class,
'showUsernameAssistanceForm')
952 $rtpl->setVariable(
'LANG_ID', $this->
lng->getLangKey());
953 $rtpl->parseCurrentBlock();
958 $rtpl->setCurrentBlock(
'homelink');
961 '?client_id=' .
CLIENT_ID .
'&lang=' . $this->
lng->getLangKey()
963 $rtpl->setVariable(
'TXT_HOME', $this->
lng->txt(
'home'));
964 $rtpl->parseCurrentBlock();
971 '[list-registration-link]',
972 'REG_PWD_CLIENT_LINKS' 981 if (0 === $this->
user->getId()) {
988 $DIC[
'legalDocuments']->loginPageHTML(TermsOfService::ID),
989 '[list-user-agreement]',
995 $DIC[
'legalDocuments']->loginPageHTML(DataProtection::ID),
996 '[list-dpro-agreement]',
1000 return $page_editor_html;
1007 '[list-language-selection]',
1008 '[list-registration-link]',
1009 '[list-user-agreement]',
1010 '[list-dpro-agreement]',
1011 '[list-login-form]',
1012 '[list-saml-login]',
1013 '[list-shibboleth-login-form]',
1014 '[list-openid-connect-login]' 1023 $field_factory = $this->ui_factory->input()->field();
1025 $keep = $field_factory->group(
1027 self::PROP_USERNAME => $field_factory->text($this->lng->txt(
'login'))->withRequired(
true),
1028 self::PROP_PASSWORD => $field_factory
1029 ->password($this->
lng->txt(
'password'))
1030 ->withRequired(
true)
1031 ->withRevelation(
true)
1032 ->withAdditionalTransformation(
1033 $this->
refinery->custom()->transformation(
1034 static function (
ILIAS\
Data\Password $value):
string {
1035 return $value->toString();
1040 $this->
lng->txt(
'auth_account_migration_keep'),
1041 $this->
lng->txt(
'auth_info_migrate')
1044 $new = $field_factory->group(
1046 $this->
lng->txt(
'auth_account_migration_new'),
1047 $this->
lng->txt(
'auth_info_add')
1051 self::PROP_ACCOUNT_MIGRATION => $field_factory->switchableGroup(
1053 self::PROP_ACCOUNT_MIGRATION_MIGRATE => $keep,
1054 self::PROP_ACCOUNT_MIGRATION_NEW => $new,
1056 $this->
lng->txt(
'auth_account_migration_name')
1057 )->withRequired(
true)->withValue(self::PROP_ACCOUNT_MIGRATION_MIGRATE)
1060 $sections = [$field_factory->section($fields, $this->
lng->txt(
'auth_account_migration'))];
1062 return $this->ui_factory->input()
1065 ->standard($this->
ctrl->getFormAction($this,
'migrateAccount'), $sections)
1066 ->withDedicatedName(
'login_form')
1067 ->withSubmitLabel($this->
lng->txt(
'save'))
1076 $this->
help->setSubScreenId(
'account_migration');
1078 $tpl = self::initStartUpTemplate(
'tpl.login_account_migration.html');
1079 $tpl->setVariable(
'MIG_FORM', $this->ui_renderer->render($form ?? $this->buildAccountMigrationForm()));
1085 self::printToGlobalTemplate($tpl);
1091 $form_valid =
false;
1093 if ($this->
http->request()->getMethod() ===
'POST') {
1094 $form = $form->withRequest($this->
http->request());
1095 $form_data = $form->getData();
1096 $form_valid = $form_data !==
null;
1104 $account_migration = $form_data[self::PROP_ACCOUNT_MIGRATION];
1105 $account_migration_mode = $account_migration[0];
1106 if ($account_migration_mode === self::PROP_ACCOUNT_MIGRATION_MIGRATE) {
1108 } elseif ($account_migration_mode === self::PROP_ACCOUNT_MIGRATION_NEW) {
1113 $this->
lng->txt(
'form_input_not_valid')
1124 $provider = $provider_factory->getProviderByAuthMode(
1129 $this->
logger->debug(
'Using provider: ' . get_class(
$provider) .
' for further processing.');
1135 $frontend = $frontend_factory->getFrontend(
1142 if ($frontend->migrateAccountNew()) {
1146 $this->
mainTemplate->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_wrong_login'));
1147 $this->
ctrl->redirect($this,
'showAccountMigration');
1155 $username = $migration_request_data[self::PROP_USERNAME];
1156 $password = $migration_request_data[self::PROP_PASSWORD];
1158 $this->
logger->debug(
'Starting account migration for user: ' .
ilSession::get(
'mig_ext_account'));
1161 $credentials->setUsername($username);
1162 $credentials->setPassword($password);
1171 $frontend = $frontend_factory->getFrontend(
1177 $frontend->authenticate();
1179 switch ($status->getStatus()) {
1181 $this->
getLogger()->debug(
'Account migration: authentication successful for ' . $username);
1183 $provider = $provider_factory->getProviderByAuthMode(
1188 $frontend = $frontend_factory->getFrontend(
1195 if ($frontend->migrateAccount(
$GLOBALS[
'DIC'][
'ilAuthSession'])) {
1199 $this->
mainTemplate->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_wrong_login'),
true);
1200 $this->
ctrl->redirect($this,
'showAccountMigration');
1204 $this->
getLogger()->info(
'Account migration failed for user ' . $username);
1211 if (!$this->authSession->isExpired() &&
1212 $this->authSession->isAuthenticated() &&
1214 $this->
ctrl->redirectToURL(ilUserUtil::getStartingPointAsUrl());
1217 $this->
help->setSubScreenId(
'logout');
1219 $tpl = self::initStartUpTemplate(
'tpl.logout.html');
1222 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->
refinery->always(
'')])
1227 $tpl->setCurrentBlock(
'homelink');
1228 $tpl->setVariable(
'CLIENT_ID',
'?client_id=' .
$client_id .
'&lang=' . $this->
lng->getLangKey());
1229 $tpl->setVariable(
'TXT_HOME', $this->
lng->txt(
'home'));
1230 $tpl->parseCurrentBlock();
1234 $tpl->setVariable(
'TXT_PAGEHEADLINE', $this->
lng->txt(
'logout'));
1235 $tpl->setVariable(
'TXT_LOGIN', $this->
lng->txt(
'login_to_ilias'));
1238 '?client_id=' .
$client_id .
'&cmd=force_login&lang=' . $this->
lng->getLangKey()
1241 self::printToGlobalTemplate($tpl);
1244 private function doLogout():
void 1247 $legal_documents = $this->dic[
'legalDocuments'];
1249 $this->eventHandler->raise(
1250 'components/ILIAS/Authentication',
1253 'user_id' => $this->
user->getId()
1257 $user_language = $this->
user->getLanguage();
1259 $used_external_auth_mode =
ilSession::get(
'used_external_auth_mode');
1262 $this->authSession->logout();
1270 $target = $legal_documents->logoutTarget($target);
1271 $url = $target->asURI();
1273 $this->eventHandler->raise(
1274 'components/ILIAS/Authentication',
1277 'username' => $this->
user->getLogin(),
1278 'is_explicit_logout' =>
true,
1279 'used_external_auth_mode' => $used_external_auth_mode,
1280 'logout_target' =>
$url 1285 $this->mainTemplate::MESSAGE_TYPE_INFO,
1286 $this->
lng->txt(
'logout_text') . $legal_documents->logoutText(),
1293 $this->
ctrl->setParameter($this,
'lang', $user_language);
1295 $this->
ctrl->redirectToURL((
string)
$url);
1301 $tpl = self::initStartUpTemplate([
'agreement.html',
'components/ILIAS/LegalDocuments'],
true,
false);
1302 $tpl->setVariable(
'CONTENT', $DIC[
'legalDocuments']->agreeContent(self::class, __FUNCTION__));
1303 self::printToGlobalTemplate($tpl);
1308 if ($this->authSession->isValid()) {
1309 if (!$this->
user->isAnonymous() || (
1311 $this->httpRequest->getServerParams()[
'SERVER_NAME']
1330 public static function _checkGoto(
string $a_target)
1334 $component_factory = $DIC[
'component.factory'];
1336 $access = $DIC->access();
1338 foreach ($component_factory->getActivePluginsInSlot(
'uihk') as $ui_plugin) {
1340 $gui_class = $ui_plugin->getUIClassInstance();
1341 $resp = $gui_class->checkGotoHook($a_target);
1342 if (isset(
$resp[
'target']) && is_string(
$resp[
'target']) &&
$resp[
'target'] !==
'') {
1343 $a_target =
$resp[
'target'];
1348 if ($a_target ===
'') {
1352 $t_arr = explode(
'_', $a_target);
1355 if ($type ===
'git') {
1359 if ($type ===
'pg' | $type ===
'st') {
1363 $class = $DIC[
'objDefinition']->getClassName($type);
1364 if ($class ===
'') {
1368 $location = $DIC[
'objDefinition']->getLocation($type);
1369 $full_class =
'ilObj' . $class .
'Access';
1371 $ret = call_user_func([$full_class,
'_checkGoto'], $a_target);
1376 !str_contains($a_target,
'_wsp') &&
1377 !$DIC->user()->isAnonymous() &&
1378 !$DIC[
'objDefinition']->isAdministrationObject($type) &&
1379 $DIC[
'objDefinition']->isRBACObject($type)) {
1382 if ($t_arr[0] ===
'pg') {
1383 if (isset($t_arr[2])) {
1389 $ref_id = array_shift($ref_ids);
1405 foreach (
$path as $path_ref_id) {
1406 $redirect_infopage =
false;
1407 $add_member_role =
false;
1413 if (!$access->
doActivationCheck(
'read',
'', $path_ref_id, $DIC->user()->getId(), $pobj_id, $ptype) ||
1414 !$access->
doStatusCheck(
'read',
'', $path_ref_id, $DIC->user()->getId(), $pobj_id, $ptype)) {
1417 } elseif ($ptype ===
'crs') {
1420 if (!$participants->isAssigned()) {
1423 $block_obj[] = $path_ref_id;
1424 $add_member_role =
true;
1426 $redirect_infopage =
true;
1429 } elseif ($ptype ===
'grp') {
1434 if ($group_obj->isRegistrationEnabled()) {
1435 $block_obj[] = $path_ref_id;
1436 $add_member_role =
true;
1438 $redirect_infopage =
true;
1444 if ($add_member_role) {
1446 $DIC->rbac()->system()->resetPACache($DIC->user()->getId(), $path_ref_id);
1447 if (!$DIC->rbac()->system()->checkAccess(
'join', $path_ref_id)) {
1448 $redirect_infopage =
true;
1450 $DIC->rbac()->system()->addTemporaryRole(
1451 $DIC->user()->getId(),
1458 if ($redirect_infopage) {
1459 if ($DIC->rbac()->system()->checkAccess(
'visible', $path_ref_id)) {
1461 'ilias.php?baseClass=ilRepositoryGUI&ref_id=' . $path_ref_id .
'&cmd=infoScreen' 1470 $DIC->rbac()->system()->resetPACache($DIC->user()->getId(),
$ref_id);
1471 if ($block_obj !== [] && $DIC->rbac()->system()->checkAccess(
'read',
$ref_id)) {
1478 'ilias.php?baseClass=ilRepositoryGUI&ref_id=' . array_shift($block_obj)
1486 private function confirmRegistration():
void 1488 $this->
lng->loadLanguageModule(
'registration');
1491 $regitration_hash = trim(
1492 $this->
http->wrapper()->query()->retrieve(
1494 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->
refinery->always(
'')])
1497 if ($regitration_hash ===
'') {
1500 $this->
lng->txt(
'reg_confirmation_hash_not_passed'),
1503 $this->
ctrl->redirectToURL(sprintf(
'./login.php?cmd=force_login&lang=%s', $this->
lng->getLangKey()));
1514 if ($oRegSettings->passwordGenerationEnabled()) {
1516 $password = $passwords[0];
1526 ))->withEmailConfirmationRegistrationMode();
1528 if ($user->
getPref(
'reg_target') ??
'') {
1529 $accountMail = $accountMail->withPermanentLinkTarget($user->
getPref(
'reg_target'));
1532 $accountMail->send($user, $password);
1536 $this->
lng->txt(
'reg_account_confirmation_successful'),
1539 $this->
ctrl->redirectToURL(sprintf(
'./login.php?cmd=force_login&lang=%s', $user->
getLanguage()));
1542 $soap_client->setResponseTimeout(1);
1543 $soap_client->enableWSDL(
true);
1544 $soap_client->init();
1547 'Triggered soap call (background process) for deletion of inactive user objects with expired confirmation hash values (dual opt in) ...' 1551 'deleteExpiredDualOptInUserObjects',
1554 $exception->getCode()
1560 $this->
lng->txt($exception->getMessage()),
1563 $this->
ctrl->redirectToURL(sprintf(
'./login.php?cmd=force_login&lang=%s', $this->
lng->getLangKey()));
1567 $this->
lng->txt($exception->getMessage()),
1570 $this->
ctrl->redirectToURL(sprintf(
'./login.php?cmd=force_login&lang=%s', $this->
lng->getLangKey()));
1580 bool $a_show_back =
false,
1581 bool $a_show_logout =
false 1587 $tpl->addBlockfile(
'CONTENT',
'content',
'tpl.startup_screen.html',
'components/ILIAS/Init');
1589 $view_title = $DIC->language()->txt(
'login_to_ilias');
1592 $param =
'client_id=' .
CLIENT_ID .
'&lang=' . $DIC->language()->getLangKey();
1594 $tpl->setCurrentBlock(
'link_item_bl');
1595 $tpl->setVariable(
'LINK_TXT', $view_title);
1596 $tpl->setVariable(
'LINK_URL',
'login.php?cmd=force_login&' .
$param);
1597 $tpl->parseCurrentBlock();
1601 $tpl->setVariable(
'LINK_URL',
'index.php?' .
$param);
1602 $tpl->setVariable(
'LINK_TXT', $DIC->language()->txt(
'home'));
1603 $tpl->parseCurrentBlock();
1605 } elseif ($a_show_logout) {
1606 $view_title = $DIC->language()->txt(
'logout');
1607 $tpl->setCurrentBlock(
'link_item_bl');
1608 $tpl->setVariable(
'LINK_TXT', $view_title);
1609 $tpl->setVariable(
'LINK_URL', self::logoutUrl());
1610 $tpl->parseCurrentBlock();
1613 if (is_array($a_tmpl)) {
1614 $template_file = $a_tmpl[0];
1615 $template_dir = $a_tmpl[1];
1617 $template_file = $a_tmpl;
1618 $template_dir =
'components/ILIAS/Init';
1621 $tpl->addBlockFile(
'STARTUP_CONTENT',
'startup_content', $template_file, $template_dir);
1623 PageContentProvider::setViewTitle($view_title);
1624 $short_title = trim($DIC->settings()->get(
'short_inst_name') ??
'');
1625 if ($short_title ===
'') {
1626 $short_title =
'ILIAS';
1628 PageContentProvider::setShortTitle($short_title);
1630 $header_title = ilObjSystemFolder::_getHeaderTitle();
1631 PageContentProvider::setTitle($header_title);
1639 $tpl =
new ilTemplate(
'tpl.login_form_saml.html',
true,
true,
'components/ILIAS/Saml');
1643 if ($target !==
'') {
1647 $tpl->setVariable(
'SAML_SCRIPT_URL',
'./saml.php' . $return);
1648 $tpl->setVariable(
'TXT_LOGIN', $this->
lng->txt(
'saml_log_in'));
1649 $tpl->setVariable(
'LOGIN_TO_ILIAS_VIA_SAML', $this->
lng->txt(
'login_to_ilias_via_saml'));
1650 $tpl->setVariable(
'TXT_SAML_LOGIN_TXT', $this->
lng->txt(
'saml_login_form_txt'));
1651 $tpl->setVariable(
'TXT_SAML_LOGIN_INFO_TXT', $this->
lng->txt(
'saml_login_form_info_txt'));
1657 '[list-saml-login]',
1662 return $page_editor_html;
1668 if ($oidc_settings->getActive()) {
1669 $tpl =
new ilTemplate(
'tpl.login_element.html',
true,
true,
'components/ILIAS/OpenIdConnect');
1671 $this->
lng->loadLanguageModule(
'auth');
1672 $tpl->setVariable(
'TXT_OIDCONNECT_HEADER', $this->
lng->txt(
'auth_oidc_login_element_info'));
1675 $target_str = empty($target) ?
'' : (
'?target=' . $target);
1676 switch ($oidc_settings->getLoginElementType()) {
1678 $tpl->setVariable(
'SCRIPT_OIDCONNECT_T',
'./openidconnect.php' . $target_str);
1679 $tpl->setVariable(
'TXT_OIDC', $oidc_settings->getLoginElemenText());
1683 $tpl->setVariable(
'SCRIPT_OIDCONNECT_I',
'./openidconnect.php' . $target_str);
1684 $tpl->setVariable(
'IMG_SOURCE', $oidc_settings->getImageFilePath());
1692 '[list-openid-connect-login]',
1693 'OPEN_ID_CONNECT_LOGIN_FORM' 1697 return $page_editor_html;
1702 $this->
getLogger()->debug(
'Trying openid connect authentication');
1705 $credentials->initFromRequest();
1714 $frontend = $frontend_factory->getFrontend(
1720 $frontend->authenticate();
1722 switch ($status->getStatus()) {
1724 $this->
logger->debug(
'Authentication successful; Redirecting to starting page.');
1725 if ($credentials->getRedirectionTarget()) {
1732 $this->
mainTemplate->setOnScreenMessage(
'failure', $status->getTranslatedReason(),
true);
1733 $this->
ctrl->redirect($this,
'showLoginPage');
1736 $this->
mainTemplate->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_wrong_login'));
1742 $this->
getLogger()->debug(
'Trying saml authentication');
1744 $params = $request->getQueryParams();
1747 $auth = $factory->auth();
1749 if (isset(
$params[
'action']) &&
$params[
'action'] ===
'logout') {
1750 $logout_url =
$params[
'logout_url'] ??
'';
1751 $this->
logger->info(sprintf(
'Requested SAML logout: %s', $logout_url));
1752 $auth->logout($logout_url);
1759 if (isset(
$params[
'returnTo'])) {
1760 $auth->storeParam(
'target',
$params[
'returnTo']);
1763 $this->
logger->debug(
'Started SAML authentication request');
1764 if (!$auth->isAuthenticated()) {
1766 if (!isset($request->getQueryParams()[
'idpentityid'], $request->getQueryParams()[
'saml_idp_id'])) {
1768 if (count($activeIdps) === 1) {
1769 $idp = current($activeIdps);
1773 'Found exactly one active IDP with id %s: %s',
1779 $this->
ctrl->setParameter($this,
'idpentityid', $idp->getEntityId());
1780 $this->
ctrl->setParameter($this,
'saml_idp_id', $idp->getIdpId());
1781 $this->
ctrl->setTargetScript(
'saml.php');
1782 $this->
ctrl->redirect($this,
'doSamlAuthentication');
1783 } elseif ($activeIdps === []) {
1784 $this->
logger->debug(
'Did not find any active IDP, skipp authentication process');
1785 $this->
ctrl->redirect($this,
'showLoginPage');
1787 $this->
logger->debug(
'Found multiple active IPDs, presenting IDP selection...');
1793 $auth->storeParam(
'idpId', (
int) $request->getQueryParams()[
'saml_idp_id']);
1794 $this->
logger->debug(sprintf(
'Stored relevant IDP id in session: %s', $auth->getParam(
'idpId')));
1797 $auth = $factory->auth();
1799 $this->
logger->debug(
'Checking SAML authentication status...');
1800 $auth->protectResource();
1802 'SAML authentication successful, continuing with ILIAS internal authentication process...' 1805 $idpId = (
int) $auth->getParam(
'idpId');
1809 'Internal SAML IDP id fetched from session: %s',
1816 'No valid internal IDP id found (most probably due to IDP initiated SSO), trying fallback determination...' 1818 $authData = $auth->getAuthDataArray();
1819 if (isset($authData[
'saml:sp:IdP'])) {
1823 'Searching active ILIAS IDP by entity id "%s" results in: %s',
1824 $authData[
'saml:sp:IdP'],
1830 'Could not execute fallback determination, no IDP entity ID found SAML authentication session data' 1835 $target = $auth->popParam(
'target');
1837 $this->
logger->debug(sprintf(
'Retrieved "target" parameter: %s', print_r($target,
true)));
1840 $credentials->initFromRequest();
1843 $provider = $provider_factory->getProviderByAuthMode(
1851 $credentials->setReturnTo($target);
1853 $target = $credentials->getReturnTo();
1860 $frontend = $frontend_factory->getFrontend(
1866 $frontend->authenticate();
1868 switch ($status->getStatus()) {
1870 $this->
logger->debug(
'Authentication successful; Redirecting to starting page.');
1875 $this->
ctrl->redirect($this,
'showAccountMigration');
1879 $this->
mainTemplate->setOnScreenMessage(
'failure', $status->getTranslatedReason(),
true);
1880 $this->
ctrl->redirect($this,
'showLoginPage');
1883 $this->
mainTemplate->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_wrong_login'));
1892 $this->
help->setSubScreenId(
'saml_idp_selection');
1894 self::initStartUpTemplate([
'tpl.saml_idp_selection.html',
'components/ILIAS/Saml']);
1896 $this->
ctrl->setTargetScript(
'saml.php');
1898 foreach ($idps as $idp) {
1899 $this->
ctrl->setParameter($this,
'saml_idp_id', $idp->getIdpId());
1900 $this->
ctrl->setParameter($this,
'idpentityid', urlencode($idp->getEntityId()));
1902 $items[] = $this->ui_factory->link()->standard(
1903 $idp->getEntityId(),
1904 $this->
ctrl->getLinkTarget($this,
'doSamlAuthentication')
1909 $this->ui_factory->panel()->standard(
1910 $this->
lng->txt(
'auth_saml_idp_selection_table_title'),
1912 $this->ui_factory->messageBox()->info($this->
lng->txt(
'auth_saml_idp_selection_table_desc')),
1913 $this->ui_factory->listing()->unordered(
1915 fn($item) => $this->ui_renderer->render($item),
1932 public static function logoutUrl(array $parameters = []): string
1936 $defaults = [
'lang' => $DIC->user()->getCurrentLanguage()];
1937 $parameters =
'&' . http_build_query(array_merge($defaults, $parameters));
1939 $DIC->ctrl()->setTargetScript(
'logout.php');
1940 $url = $DIC->ctrl()->getLinkTargetByClass([self::class],
'doLogout') . $parameters;
1941 $DIC->ctrl()->setTargetScript(
'ilias.php');
static get(string $a_var)
getSafePostCommands()
This method must return a list of safe POST commands.
setTimeLimitUnlimited(bool $a_unlimited)
const PROP_ACCOUNT_MIGRATION_MIGRATE
static _isParticipant(int $a_ref_id, int $a_usr_id)
Static function to check if a user is a participant of the container object.
static initStartUpTemplate( $a_tmpl, bool $a_show_back=false, bool $a_show_logout=false)
This method enriches the global template with some user interface elements (language selection...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupRegistrationType()
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
showLoginInformation(string $page_editor_html, ilGlobalTemplateInterface $tpl)
static getCodeValidUntil(string $code)
static setForcedCommand(string $cmd)
static getLogger(string $a_component_id)
Get component logger.
showAccountMigration(?ILIAS\UI\Component\Input\Container\Form\Form $form=null, string $message='')
static _hasMultipleAuthenticationMethods()
static _verifyRegistrationHash(string $a_hash)
Verifies a registration hash.
special template class to simplify handling of ITX/PEAR
Class ilAccountRegistrationGUI.
ilGlobalTemplateInterface $mainTemplate
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Class for user related exception handling in ILIAS.
static _isActivated(int $a_obj_id)
Is activated.
Interface Observer Contains several chained tasks and infos about them.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static _getInstanceByObjId(int $a_obj_id, int $a_usr_id)
static _getAllReferences(int $id)
get all reference ids for object ID
const string MIG_TRIGGER_AUTHMODE
const int STATUS_AUTHENTICATED
checkForcedCommand(string $cmd)
static _lookupId($a_user_str)
static goToPublicSection()
go to public section
const MESSAGE_TYPE_QUESTION
const LOGIN_ELEMENT_TYPE_TXT
const MESSAGE_TYPE_SUCCESS
static getDefaultMemberRole(int $a_ref_id)
setTimeLimitUntil(?int $a_until)
static printToGlobalTemplate($tpl)
purgePlaceholders(string $page_editor_html)
setPasswd(string $a_str, string $a_type=ilObjUser::PASSWD_PLAIN)
Auth credentials for lti oauth based authentication.
static string $forced_cmd
static _lookupObjId(int $ref_id)
const PROP_ACCOUNT_MIGRATION
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAuthPageEditorHtml(AuthPageEditorContext $ipe_context)
setActive(bool $a_active, int $a_owner=0)
set user active state and updates system fields appropriately
showOpenIdConnectLoginForm(string $page_editor_html)
showShibbolethLoginForm(string $page_editor_html)
static _existsAndNotEmpty(string $a_parent_type, int $a_id, string $a_lang="-")
checks whether page exists and is not empty (may return true on some empty pages) ...
static http()
Fetches the global http state from ILIAS.
Class ilAccountRegistrationMail.
static logoutUrl(array $parameters=[])
Return the logout URL with a valid CSRF token.
showLoginPage(?ILIAS\UI\Component\Input\Container\Form\Form $form=null)
showLoginForm(string $page_editor_html, ?ILIAS\UI\Component\Input\Container\Form\Form $form=null)
static setCookie(string $a_cookie_name, string $a_cookie_value='', bool $a_also_set_super_global=true, bool $a_set_cookie_invalid=false)
static isUnusedCode(string $code)
retrieveMessagesFromSession()
getPref(string $a_keyword)
const int SESSION_CLOSE_USER
const int STATUS_CODE_ACTIVATION_REQUIRED
buildAccountMigrationForm()
static lookupId(string $a_lang_key)
Lookup obj_id of language.
showLoginPageOrStartupPage()
showCodeForm(?string $username=null, ?ILIAS\UI\Component\Input\Container\Form\Form $form=null)
static getSyntaxStylePath()
const int STATUS_AUTHENTICATION_FAILED
const PROP_ACCOUNT_MIGRATION_NEW
doStandardAuthentication()
const int AUTH_PROVIDER_LTI
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
substituteLoginPageElements( $tpl, string $page_editor_html, string $element_html, string $placeholder, string $fallback_tplvar)
static _isAnonymous(int $usr_id)
static redirect(string $a_script)
static generatePasswords(int $a_number)
Generate a number of passwords.
setLastPasswordChangeTS(int $a_last_password_change_ts)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjAuthSettingsGUI.
static _registrationEnabled(int $a_obj_id)
Registration enabled? Method is in Access class, since it is needed by Access/ListGUI.
doMigration(array $migration_request_data)
saniziteArrayElementsTrafo()
doActivationCheck(string $a_permission, string $a_cmd, int $a_ref_id, int $a_user_id, int $a_obj_id, string $a_type)
check for activation and centralized offline status.
const int CONTEXT_STANDARD_FORM
Authentication with id and password.
static useCode(string $code)
showRegistrationLinks(string $page_editor_html)
ilAuthSession $authSession
static redirectToStartingPage(string $target='')
static getInstance()
Get status instance.
static setClosingContext(int $a_context)
set closing context (for statistics)
showLegalDocumentsLinks(string $page_editor_html)
ILIAS UI Factory $ui_factory
ilAppEventHandler $eventHandler
showSamlIdpSelection(ilSamlAuth $auth, array $idps)
static _lookupContObjID(int $a_id)
get learning module id for lm object
static geIdpIdByEntityId(string $entityId)
RefineryFactory $refinery
static _getMultipleAuthModeOptions(ilLanguage $lng)
language()
description: > Example for rendring a language glyph.
const MESSAGE_TYPE_FAILURE
Class for user related exception handling in ILIAS.
ServerRequestInterface $httpRequest
static getInstance(AuthPageEditorContext $context)
static getActiveIdpList()
static applyRoleAssignments(ilObjUser $user, string $code)
const LOGIN_ELEMENT_TYPE_IMG
static _lookupType(int $id, bool $reference=false)
const string MIG_EXTERNAL_ACCOUNT
doOpenIdConnectAuthentication()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getAuthSettingsRefId()
getUnsafeGetCommands()
This method must return a list of unsafe GET commands.
static set(string $a_var, $a_val)
Set a value.
__construct(?ilObjUser $user=null, ?ilGlobalTemplateInterface $mainTemplate=null, ?ServerRequestInterface $httpRequest=null)
ILIAS UI Renderer $ui_renderer
static applyAccessLimits(ilObjUser $user, string $code)
const int AUTH_OPENID_CONNECT
jumpToPasswordAssistance()
showSamlLoginForm(string $page_editor_html)
doStatusCheck(string $a_permission, string $a_cmd, int $a_ref_id, int $a_user_id, int $a_obj_id, string $a_type)
object type specific check
buildCodeForm(?string $username=null)
static _lookupLogin(int $a_user_id)
const int STATUS_ACCOUNT_MIGRATION_REQUIRED