ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilStartUpGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4use Psr\Http\Message\ServerRequestInterface;
6
17{
20
22 protected $ctrl;
23 protected $lng;
24
28 protected $logger;
29
31 protected $mainTemplate;
32
34 protected $user;
35
38
40 protected $httpRequest;
41
49 public function __construct(
50 \ilObjUser $user = null,
53 ServerRequestInterface $httpRequest = null
54 ) {
55 global $DIC;
56
57 if ($user === null) {
58 $user = $DIC->user();
59 }
60 $this->user = $user;
61
62 if ($termsOfServiceEvaluation === null) {
63 $termsOfServiceEvaluation = $DIC['tos.document.evaluator'];
64 }
65 $this->termsOfServiceEvaluation = $termsOfServiceEvaluation;
66
67 if ($mainTemplate === null) {
68 $mainTemplate = $DIC->ui()->mainTemplate();
69 }
70 $this->mainTemplate = $mainTemplate;
71
72 if ($httpRequest === null) {
73 $httpRequest = $DIC->http()->request();
74 }
75 $this->httpRequest = $httpRequest;
76
77 $this->ctrl = $DIC->ctrl();
78 $this->lng = $DIC->language();
79 $this->lng->loadLanguageModule('auth');
80 $this->logger = ilLoggerFactory::getLogger('init');
81
82 $this->ctrl->saveParameter($this, array("rep_ref_id", "lang", "target", "client_id"));
83
84 $this->user->setLanguage($this->lng->getLangKey());
85 }
86
91 public function executeCommand()
92 {
93 $cmd = $this->ctrl->getCmd("processIndexPHP", array('processIndexPHP','showLoginPage'));
94 $next_class = $this->ctrl->getNextClass($this);
95
96 switch ($next_class) {
97 case 'ilLoginPageGUI':
98 break;
99
100 case "ilaccountregistrationgui":
101 require_once("Services/Registration/classes/class.ilAccountRegistrationGUI.php");
102 return $this->ctrl->forwardCommand(new ilAccountRegistrationGUI());
103
104 case "ilpasswordassistancegui":
105 require_once("Services/Init/classes/class.ilPasswordAssistanceGUI.php");
106 return $this->ctrl->forwardCommand(new ilPasswordAssistanceGUI());
107
108 default:
109 if (method_exists($this, $cmd)) {
110 return $this->$cmd();
111 }
112 }
113 }
114
119 public function getLogger()
120 {
121 return $this->logger;
122 }
123
128 public function jumpToRegistration()
129 {
130 $this->ctrl->setCmdClass("ilaccountregistrationgui");
131 $this->ctrl->setCmd("");
132 $this->executeCommand();
133 }
134
139 public function jumpToPasswordAssistance()
140 {
141 $this->ctrl->setCmdClass("ilpasswordassistancegui");
142 $this->ctrl->setCmd("");
143 $this->executeCommand();
144 }
145
149 protected function showLoginPageOrStartupPage()
150 {
151
155 $auth_session = $GLOBALS['DIC']['ilAuthSession'];
156 $ilAppEventHandler = $GLOBALS['DIC']['ilAppEventHandler'];
157
158 $force_login = false;
159 if (
160 !is_array($_REQUEST['cmd']) &&
161 strcmp($_REQUEST['cmd'], 'force_login') === 0
162 ) {
163 $force_login = true;
164 }
165
166 if ($force_login) {
167 $this->logger->debug('Force login');
168 if ($auth_session->isValid()) {
169 $this->logger->debug('Valid session -> logout current user');
171 $auth_session->logout();
172
173 $ilAppEventHandler->raise(
174 'Services/Authentication',
175 'afterLogout',
176 array(
177 'username' => $this->user->getLogin()
178 )
179 );
180 }
181 $this->logger->debug('Show login page');
182 return $this->showLoginPage();
183 }
184
188 if ($auth_session->isValid()) {
189 $this->logger->debug('Valid session -> redirect to starting page');
190 return ilInitialisation::redirectToStartingPage();
191 }
192 $this->logger->debug('No valid session -> show login');
193 $this->showLoginPage();
194 }
195
196
202 protected function showLoginPage(ilPropertyFormGUI $form = null)
203 {
204 global $tpl, $ilSetting;
205
206
207 $this->getLogger()->debug('Showing login page');
208
209 $extUid = '';
210 if (isset($_GET['ext_uid']) && is_string($_GET['ext_uid'])) {
211 $extUid = $_GET['ext_uid'];
212 }
213 $soapPw = '';
214 if (isset($_GET['soap_pw']) && is_string($_GET['soap_pw'])) {
215 $soapPw = $_GET['soap_pw'];
216 }
217
218 require_once 'Services/Authentication/classes/Frontend/class.ilAuthFrontendCredentialsSoap.php';
219 $credentials = new ilAuthFrontendCredentialsSoap($GLOBALS['DIC']->http()->request(), $this->ctrl, $ilSetting);
220 $credentials->setUsername(ilUtil::stripSlashes($extUid));
221 $credentials->setPassword(ilUtil::stripSlashes($soapPw));
222 $credentials->tryAuthenticationOnLoginPage();
223
224 // try apache auth
225 include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendCredentialsApache.php';
226 $frontend = new ilAuthFrontendCredentialsApache($this->httpRequest, $this->ctrl);
227 $frontend->tryAuthenticationOnLoginPage();
228
229 // Instantiate login template
230 $tpl = self::initStartUpTemplate("tpl.login.html");
231
232 $this->mainTemplate->addCss(ilObjStyleSheet::getContentStylePath(0));
233 $this->mainTemplate->addCss(ilObjStyleSheet::getSyntaxStylePath());
234
235 $page_editor_html = $this->getLoginPageEditorHTML();
236 $page_editor_html = $this->showOpenIdConnectLoginForm($page_editor_html);
237 $page_editor_html = $this->showLoginInformation($page_editor_html, $tpl);
238 $page_editor_html = $this->showLoginForm($page_editor_html, $form);
239 $page_editor_html = $this->showCASLoginForm($page_editor_html);
240 $page_editor_html = $this->showShibbolethLoginForm($page_editor_html);
241 $page_editor_html = $this->showSamlLoginForm($page_editor_html);
242 $page_editor_html = $this->showRegistrationLinks($page_editor_html);
243 $page_editor_html = $this->showTermsOfServiceLink($page_editor_html);
244
245 $page_editor_html = $this->purgePlaceholders($page_editor_html);
246
247 // check expired session and send message
248 if ($GLOBALS['DIC']['ilAuthSession']->isExpired()) {
249 ilUtil::sendFailure($GLOBALS['lng']->txt('auth_err_expired'));
250 }
251
252 if (strlen($page_editor_html)) {
253 $tpl->setVariable('LPE', $page_editor_html);
254 }
255
257 }
258
259
260 public static function printToGlobalTemplate($tpl)
261 {
262 global $DIC;
263 $gtpl = $DIC['tpl'];
264 $gtpl->setContent($tpl->get());
265 $gtpl->printToStdout("DEFAULT", false, true);
266 }
267
268 protected function showCodeForm($a_username = null, $a_form = null)
269 {
270 global $tpl, $lng;
271
272 self::initStartUpTemplate("tpl.login_reactivate_code.html");
273
274 ilUtil::sendFailure($lng->txt("time_limit_reached"));
275
276 if (!$a_form) {
277 $a_form = $this->initCodeForm($a_username);
278 }
279
280 $tpl->setVariable("FORM", $a_form->getHTML());
281 $tpl->printToStdout("DEFAULT", false);
282 }
283
284 protected function initCodeForm($a_username)
285 {
286 global $lng, $ilCtrl;
287
288 $lng->loadLanguageModule("auth");
289
290 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
291
292 $form = new ilPropertyFormGUI();
293 $form->setFormAction($ilCtrl->getFormAction($this, 'showcodeform'));
294 $form->setTitle($lng->txt('auth_account_code_title'));
295
296 $count = new ilTextInputGUI($lng->txt('auth_account_code'), 'code');
297 $count->setRequired(true);
298 $count->setInfo($lng->txt('auth_account_code_info'));
299 $form->addItem($count);
300
301 // #11658
302 $uname = new ilHiddenInputGUI("uname");
303 $uname->setValue($a_username);
304 $form->addItem($uname);
305
306 $form->addCommandButton('processCode', $lng->txt('send'));
307
308 return $form;
309 }
310
318 protected function processCode()
319 {
320 global $lng, $ilAuth, $ilCtrl;
321
322 $uname = $_POST["uname"];
323
324 $form = $this->initCodeForm($uname);
325 if ($uname && $form->checkInput()) {
326 $code = $form->getInput("code");
327
328 include_once "Services/User/classes/class.ilAccountCode.php";
329 if (ilAccountCode::isUnusedCode($code)) {
330 $valid_until = ilAccountCode::getCodeValidUntil($code);
331
332 if (!$user_id = ilObjUser::_lookupId($uname)) {
333 $this->showLoginPage();
334 return false;
335 }
336
337 $invalid_code = false;
338 $user = new ilObjUser($user_id);
339
340 if ($valid_until === "0") {
341 $user->setTimeLimitUnlimited(true);
342 } else {
343 if (is_numeric($valid_until)) {
344 $valid_until = strtotime("+" . $valid_until . "days");
345 } else {
346 $valid_until = explode("-", $valid_until);
347 $valid_until = mktime(
348 23,
349 59,
350 59,
351 $valid_until[1],
352 $valid_until[2],
353 $valid_until[0]
354 );
355 if ($valid_until < time()) {
356 $invalid_code = true;
357 }
358 }
359
360 if (!$invalid_code) {
361 $user->setTimeLimitUnlimited(false);
362 $user->setTimeLimitUntil($valid_until);
363 }
364 }
365
366 if (!$invalid_code) {
367 $user->setActive(true);
368
370
371 // apply registration code role assignments
373
374 // apply registration code time limits
376
377 $user->update();
378
379 $ilCtrl->setParameter($this, "cu", 1);
380 $GLOBALS['DIC']->language()->loadLanguageModule('auth');
381 ilUtil::sendSuccess($GLOBALS['DIC']->language()->txt('auth_activation_code_success'), true);
382 $ilCtrl->redirect($this, "showLoginPage");
383 }
384 }
385
386 $lng->loadLanguageModule("user");
387 $field = $form->getItemByPostVar("code");
388 $field->setAlert($lng->txt("user_account_code_not_valid"));
389 }
390
391 $form->setValuesByPost();
392 $this->showCodeForm($uname, $form);
393 }
394
395
400 protected function initStandardLoginForm()
401 {
402 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
403 $form = new ilPropertyFormGUI();
404 $form->setFormAction($this->ctrl->getFormAction($this, ''));
405 $form->setName("formlogin");
406 $form->setShowTopButtons(false);
407 $form->setTitle($this->lng->txt("login_to_ilias"));
408
409 include_once './Services/Authentication/classes/class.ilAuthModeDetermination.php';
411
412 if (ilAuthUtils::_hasMultipleAuthenticationMethods() and $det->isManualSelection()) {
413 $visible_auth_methods = array();
414 $radg = new ilRadioGroupInputGUI($this->lng->txt("auth_selection"), "auth_mode");
415 foreach (ilAuthUtils::_getMultipleAuthModeOptions($this->lng) as $key => $option) {
416 if (isset($option['hide_in_ui']) && $option['hide_in_ui']) {
417 continue;
418 }
419
420 $op1 = new ilRadioOption($option['txt'], $key);
421 $radg->addOption($op1);
422 if (isset($option['checked'])) {
423 $radg->setValue($key);
424 }
425 $visible_auth_methods[] = $op1;
426 }
427
428 if (count($visible_auth_methods) == 1) {
429 $first_auth_method = current($visible_auth_methods);
430 $hidden_auth_method = new ilHiddenInputGUI("auth_mode");
431 $hidden_auth_method->setValue($first_auth_method->getValue());
432 $form->addItem($hidden_auth_method);
433 } else {
434 $form->addItem($radg);
435 }
436 }
437
438 $ti = new ilTextInputGUI($this->lng->txt("username"), "username");
439 $ti->setSize(20);
440 $ti->setRequired(true);
441 $form->addItem($ti);
442
443 $pi = new ilPasswordInputGUI($this->lng->txt("password"), "password");
444 $pi->setUseStripSlashes(false);
445 $pi->setRetype(false);
446 $pi->setSkipSyntaxCheck(true);
447 $pi->setSize(20);
448 $pi->setDisableHtmlAutoComplete(false);
449 $pi->setRequired(true);
450 $form->addItem($pi);
451
452 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
453 if (ilCaptchaUtil::isActiveForLogin()) {
454 require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
455 $captcha = new ilCaptchaInputGUI($this->lng->txt('captcha_code'), 'captcha_code');
456 $captcha->setRequired(true);
457 $form->addItem($captcha);
458 }
459
460 $form->addCommandButton("doStandardAuthentication", $this->lng->txt("log_in"));
461
462 return $form;
463 }
464
468 protected function doShibbolethAuthentication()
469 {
470 $this->getLogger()->debug('Trying shibboleth authentication');
471
472 include_once './Services/AuthShibboleth/classes/class.ilAuthFrontendCredentialsShibboleth.php';
473 $credentials = new ilAuthFrontendCredentialsShibboleth();
474 $credentials->initFromRequest();
475
476 include_once './Services/Authentication/classes/Provider/class.ilAuthProviderFactory.php';
477 $provider_factory = new ilAuthProviderFactory();
478 $provider = $provider_factory->getProviderByAuthMode($credentials, AUTH_SHIBBOLETH);
479
480 include_once './Services/Authentication/classes/class.ilAuthStatus.php';
481 $status = ilAuthStatus::getInstance();
482
483 include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendFactory.php';
484 $frontend_factory = new ilAuthFrontendFactory();
485 $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
486 $frontend = $frontend_factory->getFrontend(
487 $GLOBALS['DIC']['ilAuthSession'],
488 $status,
489 $credentials,
490 array($provider)
491 );
492
493 $frontend->authenticate();
494
495 switch ($status->getStatus()) {
497 ilLoggerFactory::getLogger('auth')->debug('Authentication successful; Redirecting to starting page.');
498 include_once './Services/Init/classes/class.ilInitialisation.php';
499 ilInitialisation::redirectToStartingPage();
500 return;
501
503 return $GLOBALS['ilCtrl']->redirect($this, 'showAccountMigration');
504
506 ilUtil::sendFailure($status->getTranslatedReason(), true);
507 $GLOBALS['ilCtrl']->redirect($this, 'showLoginPage');
508 return false;
509 }
510
511 ilUtil::sendFailure($this->lng->txt('err_wrong_login'));
512 $this->showLoginPage();
513 return false;
514 }
515
519 protected function doCasAuthentication()
520 {
521 global $DIC;
522
523 $this->getLogger()->debug('Trying cas authentication');
524
525 include_once './Services/CAS/classes/class.ilAuthFrontendCredentialsCAS.php';
526 $credentials = new ilAuthFrontendCredentialsCAS();
527
528 include_once './Services/Authentication/classes/Provider/class.ilAuthProviderFactory.php';
529 $provider_factory = new ilAuthProviderFactory();
530 $provider = $provider_factory->getProviderByAuthMode($credentials, AUTH_CAS);
531
532 include_once './Services/Authentication/classes/class.ilAuthStatus.php';
533 $status = ilAuthStatus::getInstance();
534
535 include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendFactory.php';
536 $frontend_factory = new ilAuthFrontendFactory();
537 $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
538 $frontend = $frontend_factory->getFrontend(
539 $GLOBALS['DIC']['ilAuthSession'],
540 $status,
541 $credentials,
542 array($provider)
543 );
544
545 $frontend->authenticate();
546 switch ($status->getStatus()) {
548 $this->getLogger()->debug('Authentication successful.');
549 ilInitialisation::redirectToStartingPage();
550 break;
551
553 default:
554 ilUtil::sendFailure($DIC->language()->txt($status->getReason()));
555 $this->showLoginPage();
556 return false;
557 }
558 }
559
563 protected function doLTIAuthentication()
564 {
565 $this->getLogger()->debug('Trying lti authentication');
566
567 $credentials = new ilAuthFrontendCredentialsLTI();
568 $credentials->initFromRequest();
569
570 $provider_factory = new ilAuthProviderFactory();
571 $provider = $provider_factory->getProviderByAuthMode($credentials, AUTH_PROVIDER_LTI);
572
573 $status = ilAuthStatus::getInstance();
574
575 $frontend_factory = new ilAuthFrontendFactory();
576 $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
577 $frontend = $frontend_factory->getFrontend(
578 $GLOBALS['DIC']['ilAuthSession'],
579 $status,
580 $credentials,
581 array($provider)
582 );
583
584 $frontend->authenticate();
585
586 switch ($status->getStatus()) {
588 ilLoggerFactory::getLogger('auth')->debug('Authentication successful; Redirecting to starting page.');
589 ilInitialisation::redirectToStartingPage();
590 return;
591
593 return $GLOBALS['ilCtrl']->redirect($this, 'showAccountMigration');
594
596 ilUtil::sendFailure($GLOBALS['lng']->txt($status->getReason()), true);
597 $GLOBALS['ilCtrl']->redirect($this, 'showLoginPage');
598 return false;
599 }
600
601 ilUtil::sendFailure($this->lng->txt('err_wrong_login'));
602 $this->showLoginPage();
603 return false;
604 }
605
606
610 protected function doApacheAuthentication()
611 {
612 $this->getLogger()->debug('Trying apache authentication');
613
614 $credentials = new \ilAuthFrontendCredentialsApache($this->httpRequest, $this->ctrl);
615 $credentials->initFromRequest();
616
617 $provider_factory = new \ilAuthProviderFactory();
618 $provider = $provider_factory->getProviderByAuthMode($credentials, AUTH_APACHE);
619
620 $status = \ilAuthStatus::getInstance();
621
622 $frontend_factory = new \ilAuthFrontendFactory();
623 $frontend_factory->setContext(\ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
624 $frontend = $frontend_factory->getFrontend(
625 $GLOBALS['DIC']['ilAuthSession'],
626 $status,
627 $credentials,
628 array($provider)
629 );
630
631 $frontend->authenticate();
632
633 switch ($status->getStatus()) {
634 case \ilAuthStatus::STATUS_AUTHENTICATED:
635 if ($credentials->hasValidTargetUrl()) {
636 \ilLoggerFactory::getLogger('auth')->debug(sprintf(
637 'Authentication successful. Redirecting to starting page: %s',
638 $credentials->getTargetUrl()
639 ));
640 $this->ctrl->redirectToURL($credentials->getTargetUrl());
641 } else {
642 \ilLoggerFactory::getLogger('auth')->debug(
643 'Authentication successful, but no valid target URL given. Redirecting to default starting page.'
644 );
645 \ilInitialisation::redirectToStartingPage();
646 }
647 break;
648
649 case \ilAuthStatus::STATUS_ACCOUNT_MIGRATION_REQUIRED:
650 $this->ctrl->redirect($this, 'showAccountMigration');
651 break;
652
653 case \ilAuthStatus::STATUS_AUTHENTICATION_FAILED:
654 \ilUtil::sendFailure($status->getTranslatedReason(), true);
655 $this->ctrl->redirectToURL(\ilUtil::appendUrlParameterString(
656 $this->ctrl->getLinkTarget($this, 'showLoginPage', '', false, false),
657 'passed_sso=1'
658 ));
659 break;
660 }
661
662 \ilUtil::sendFailure($this->lng->txt('err_wrong_login'));
663 $this->showLoginPage();
664 return false;
665 }
666
670 protected function doStandardAuthentication()
671 {
672 $form = $this->initStandardLoginForm();
673 if ($form->checkInput()) {
674 $this->getLogger()->debug('Trying to authenticate user.');
675
676 include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendCredentials.php';
677 $credentials = new ilAuthFrontendCredentials();
678 $credentials->setUsername($form->getInput('username'));
679 $credentials->setPassword($form->getInput('password'));
680 $credentials->setCaptchaCode($form->getInput('captcha_code'));
681
682 // set chosen auth mode
683 include_once './Services/Authentication/classes/class.ilAuthModeDetermination.php';
685 if (ilAuthUtils::_hasMultipleAuthenticationMethods() and $det->isManualSelection()) {
686 $credentials->setAuthMode($form->getInput('auth_mode'));
687 }
688
689 include_once './Services/Authentication/classes/Provider/class.ilAuthProviderFactory.php';
690 $provider_factory = new ilAuthProviderFactory();
691 $providers = $provider_factory->getProviders($credentials);
692
693 include_once './Services/Authentication/classes/class.ilAuthStatus.php';
694 $status = ilAuthStatus::getInstance();
695
696 include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendFactory.php';
697 $frontend_factory = new ilAuthFrontendFactory();
698 $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
699 $frontend = $frontend_factory->getFrontend(
700 $GLOBALS['DIC']['ilAuthSession'],
701 $status,
702 $credentials,
703 $providers
704 );
705
706 $frontend->authenticate();
707
708 switch ($status->getStatus()) {
710 ilLoggerFactory::getLogger('auth')->debug('Authentication successful; Redirecting to starting page.');
711 include_once './Services/Init/classes/class.ilInitialisation.php';
712 ilInitialisation::redirectToStartingPage();
713 return;
714
716 $uname = ilObjUser::_lookupLogin($status->getAuthenticatedUserId());
717 return $this->showLoginPage($this->initCodeForm($uname));
718
720 return $GLOBALS['ilCtrl']->redirect($this, 'showAccountMigration');
721
723 ilUtil::sendFailure($status->getTranslatedReason());
724 return $this->showLoginPage($form);
725 }
726 }
727 ilUtil::sendFailure($this->lng->txt('err_wrong_login'));
728 $this->showLoginPage($form);
729 return false;
730 }
731
732
733
734
735
741 protected function showLoginForm($page_editor_html, ilPropertyFormGUI $form = null)
742 {
743 global $ilSetting,$lng,$tpl;
744
745 // @todo move this to auth utils.
746 // login via ILIAS (this also includes radius and ldap)
747 // If local authentication is enabled for shibboleth users, we
748 // display the login form for ILIAS here.
749 if (($ilSetting->get("auth_mode") != AUTH_SHIBBOLETH ||
750 $ilSetting->get("shib_auth_allow_local")) &&
751 $ilSetting->get("auth_mode") != AUTH_CAS) {
752 if (!$form instanceof ilPropertyFormGUI) {
753 $form = $this->initStandardLoginForm();
754 }
755
756 return $this->substituteLoginPageElements(
757 $tpl,
758 $page_editor_html,
759 $form->getHTML(),
760 '[list-login-form]',
761 'LOGIN_FORM'
762 );
763 }
764 return $page_editor_html;
765 }
766
772 protected function showLoginInformation($page_editor_html, $tpl)
773 {
774 global $lng;
775
776 if (strlen($page_editor_html)) {
777 // page editor active return
778 return $page_editor_html;
779 }
780
781 $loginSettings = new ilSetting("login_settings");
782 $information = $loginSettings->get("login_message_" . $lng->getLangKey());
783
784 if (strlen(trim($information))) {
785 $tpl->setVariable("TXT_LOGIN_INFORMATION", $information);
786 }
787 return $page_editor_html;
788 }
789
796 protected function showCASLoginForm($page_editor_html)
797 {
798 global $ilSetting, $lng;
799
800
801 // cas login link
802 if ($ilSetting->get("cas_active")) {
803 $tpl = new ilTemplate('tpl.login_form_cas.html', true, true, 'Services/Init');
804 $tpl->setVariable("TXT_CAS_LOGIN", $lng->txt("login_to_ilias_via_cas"));
805 $tpl->setVariable("TXT_CAS_LOGIN_BUTTON", ilUtil::getImagePath("cas_login_button.png"));
806 $tpl->setVariable("TXT_CAS_LOGIN_INSTRUCTIONS", $ilSetting->get("cas_login_instructions"));
807 $this->ctrl->setParameter($this, "forceCASLogin", "1");
808 $tpl->setVariable("TARGET_CAS_LOGIN", $this->ctrl->getLinkTarget($this, "doCasAuthentication"));
809 $this->ctrl->setParameter($this, "forceCASLogin", "");
810
811 return $this->substituteLoginPageElements(
812 $GLOBALS['tpl'],
813 $page_editor_html,
814 $tpl->get(),
815 '[list-cas-login-form]',
816 'CAS_LOGIN_FORM'
817 );
818 }
819 return $page_editor_html;
820 }
821
827 protected function showShibbolethLoginForm($page_editor_html)
828 {
829 global $ilSetting, $lng;
830
831 // Refactoring with ilFormPropertyGUI
832 // [...]
833
834 // shibboleth login link
835 if ($ilSetting->get("shib_active")) {
836 $tpl = new ilTemplate('tpl.login_form_shibboleth.html', true, true, 'Services/Init');
837
838 $tpl->setVariable('SHIB_FORMACTION', './shib_login.php'); // Bugfix http://ilias.de/mantis/view.php?id=10662 {$tpl->setVariable('SHIB_FORMACTION', $this->ctrl->getFormAction($this));}
839 $federation_name = $ilSetting->get("shib_federation_name");
840 $admin_mail = ' <a href="mailto:' . $ilSetting->get("admin_email") . '">ILIAS ' . $lng->txt(
841 "administrator"
842 ) . '</a>.';
843 if ($ilSetting->get("shib_hos_type") == 'external_wayf') {
844 $tpl->setCurrentBlock("shibboleth_login");
845 $tpl->setVariable("TXT_SHIB_LOGIN", $lng->txt("login_to_ilias_via_shibboleth"));
846 $tpl->setVariable("IL_TARGET", $_GET["target"]);
847 $tpl->setVariable("TXT_SHIB_FEDERATION_NAME", $ilSetting->get("shib_federation_name"));
848 $tpl->setVariable("TXT_SHIB_LOGIN_BUTTON", $ilSetting->get("shib_login_button"));
849 $tpl->setVariable(
850 "TXT_SHIB_LOGIN_INSTRUCTIONS",
851 sprintf(
852 $lng->txt("shib_general_login_instructions"),
853 $federation_name,
854 $admin_mail
855 )
856 );
857 $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS", $ilSetting->get("shib_login_instructions"));
858 $tpl->parseCurrentBlock();
859 } elseif ($ilSetting->get("shib_hos_type") == 'embedded_wayf') {
860 $tpl->setCurrentBlock("shibboleth_custom_login");
861 $customInstructions = stripslashes($ilSetting->get("shib_login_instructions"));
862 $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS", $customInstructions);
863 $tpl->parseCurrentBlock();
864 } else {
865 $tpl->setCurrentBlock("shibboleth_wayf_login");
866 $tpl->setVariable("TXT_SHIB_LOGIN", $lng->txt("login_to_ilias_via_shibboleth"));
867 $tpl->setVariable("TXT_SHIB_FEDERATION_NAME", $ilSetting->get("shib_federation_name"));
868 $tpl->setVariable("TXT_SELECT_HOME_ORGANIZATION", sprintf($lng->txt("shib_select_home_organization"), $ilSetting->get("shib_federation_name")));
869 $tpl->setVariable("TXT_CONTINUE", $lng->txt("btn_next"));
870 $tpl->setVariable("TXT_SHIB_HOME_ORGANIZATION", $lng->txt("shib_home_organization"));
871 $tpl->setVariable(
872 "TXT_SHIB_LOGIN_INSTRUCTIONS",
873 sprintf(
874 $lng->txt("shib_general_wayf_login_instructions"),
875 $admin_mail
876 )
877 );
878 $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS", $ilSetting->get("shib_login_instructions"));
879
880 require_once "./Services/AuthShibboleth/classes/class.ilShibbolethWAYF.php";
881 $WAYF = new ShibWAYF();
882
883 $tpl->setVariable("TXT_SHIB_INVALID_SELECTION", $WAYF->showNotice());
884 $tpl->setVariable("SHIB_IDP_LIST", $WAYF->generateSelection());
885 $tpl->setVariable("ILW_TARGET", $_GET["target"]);
886 $tpl->parseCurrentBlock();
887 }
888
889 return $this->substituteLoginPageElements($GLOBALS['tpl'], $page_editor_html, $tpl->get(), '[list-shibboleth-login-form]', 'SHIB_LOGIN_FORM');
890 }
891
892 return $page_editor_html;
893 }
894
895
905 protected function substituteLoginPageElements($tpl, $page_editor_html, $element_html, $placeholder, $fallback_tplvar)
906 {
907 if (!strlen($page_editor_html)) {
908 $tpl->setVariable($fallback_tplvar, $element_html);
909 return $page_editor_html;
910 }
911 // Try to replace placeholders
912 if (!stristr($page_editor_html, $placeholder)) {
913 $tpl->setVariable($fallback_tplvar, $element_html);
914 return $page_editor_html;
915 }
916 return str_replace($placeholder, $element_html, $page_editor_html);
917 }
918
923 protected function getLoginPageEditorHTML()
924 {
925 global $lng, $tpl;
926
927 include_once './Services/Authentication/classes/class.ilAuthLoginPageEditorSettings.php';
929 $active_lang = $lpe->getIliasEditorLanguage($lng->getLangKey());
930
931 if (!$active_lang) {
932 return '';
933 }
934
935 // if page does not exist, return nothing
936 include_once './Services/COPage/classes/class.ilPageUtil.php';
937 if (!ilPageUtil::_existsAndNotEmpty('auth', ilLanguage::lookupId($active_lang))) {
938 return '';
939 }
940
941 // get page object
942 $page_gui = new ilLoginPageGUI(ilLanguage::lookupId($active_lang));
943
944 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
945 $page_gui->setStyleId(0, 'auth');
946
947 $page_gui->setPresentationTitle("");
948 $page_gui->setTemplateOutput(false);
949 $page_gui->setHeader("");
950 $ret = $page_gui->showPage();
951
952 return $ret;
953 }
954
963 protected function showRegistrationLinks($page_editor_html)
964 {
965 global $lng, $ilSetting, $ilIliasIniFile, $ilAccess;
966
967 $rtpl = new ilTemplate('tpl.login_registration_links.html', true, true, 'Services/Init');
968
969 // allow new registrations?
970 include_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
972 $rtpl->setCurrentBlock("new_registration");
973 $rtpl->setVariable("REGISTER", $lng->txt("registration"));
974 $rtpl->setVariable(
975 "CMD_REGISTER",
976 $this->ctrl->getLinkTargetByClass("ilaccountregistrationgui", "")
977 );
978 $rtpl->parseCurrentBlock();
979 }
980 // allow password assistance? Surpress option if Authmode is not local database
981 if ($ilSetting->get("password_assistance")) {
982 $rtpl->setCurrentBlock("password_assistance");
983 $rtpl->setVariable("FORGOT_PASSWORD", $lng->txt("forgot_password"));
984 $rtpl->setVariable("FORGOT_USERNAME", $lng->txt("forgot_username"));
985 $rtpl->setVariable(
986 "CMD_FORGOT_PASSWORD",
987 $this->ctrl->getLinkTargetByClass("ilpasswordassistancegui", "")
988 );
989 $rtpl->setVariable(
990 "CMD_FORGOT_USERNAME",
991 $this->ctrl->getLinkTargetByClass("ilpasswordassistancegui", "showUsernameAssistanceForm")
992 );
993 $rtpl->setVariable("LANG_ID", $lng->getLangKey());
994 $rtpl->parseCurrentBlock();
995 }
996
997 if (ilPublicSectionSettings::getInstance()->isEnabledForDomain($_SERVER['SERVER_NAME']) &&
998 $ilAccess->checkAccessOfUser(ANONYMOUS_USER_ID, "read", "", ROOT_FOLDER_ID)) {
999 $rtpl->setCurrentBlock("homelink");
1000 $rtpl->setVariable("CLIENT_ID", "?client_id=" . $_COOKIE["ilClientId"] . "&lang=" . $lng->getLangKey());
1001 $rtpl->setVariable("TXT_HOME", $lng->txt("home"));
1002 $rtpl->parseCurrentBlock();
1003 }
1004
1005 if ($ilIliasIniFile->readVariable("clients", "list")) {
1006 $rtpl->setCurrentBlock("client_list");
1007 $rtpl->setVariable("TXT_CLIENT_LIST", $lng->txt("to_client_list"));
1008 $rtpl->setVariable("CMD_CLIENT_LIST", $this->ctrl->getLinkTarget($this, "showClientList"));
1009 $rtpl->parseCurrentBlock();
1010 }
1011
1012 return $this->substituteLoginPageElements(
1013 $GLOBALS['tpl'],
1014 $page_editor_html,
1015 $rtpl->get(),
1016 '[list-registration-link]',
1017 'REG_PWD_CLIENT_LINKS'
1018 );
1019 }
1020
1026 protected function showTermsOfServiceLink(string $page_editor_html) : string
1027 {
1028 if (!$this->user->getId()) {
1029 $this->user->setId(ANONYMOUS_USER_ID);
1030 }
1031
1032 if (\ilTermsOfServiceHelper::isEnabled() && $this->termsOfServiceEvaluation->hasDocument()) {
1033 $utpl = new ilTemplate('tpl.login_terms_of_service_link.html', true, true, 'Services/Init');
1034 $utpl->setVariable('TXT_TERMS_OF_SERVICE', $this->lng->txt('usr_agreement'));
1035 $utpl->setVariable('LINK_TERMS_OF_SERVICE', $this->ctrl->getLinkTarget($this, 'showTermsOfService'));
1036
1037 return $this->substituteLoginPageElements(
1038 $GLOBALS['tpl'],
1039 $page_editor_html,
1040 $utpl->get(),
1041 '[list-user-agreement]',
1042 'USER_AGREEMENT'
1043 );
1044 }
1045
1046 return $this->substituteLoginPageElements(
1047 $GLOBALS['tpl'],
1048 $page_editor_html,
1049 '',
1050 '[list-user-agreement]',
1051 'USER_AGREEMENT'
1052 );
1053 }
1054
1060 protected function purgePlaceholders($page_editor_html)
1061 {
1062 return str_replace(
1063 array(
1064 '[list-language-selection] ',
1065 '[list-registration-link]',
1066 '[list-user-agreement]',
1067 '[list-login-form]',
1068 '[list-cas-login-form]',
1069 '[list-saml-login]',
1070 '[list-shibboleth-login-form]'
1071 ),
1072 array('','','','','','',''),
1073 $page_editor_html
1074 );
1075 }
1076
1081 public function showAccountMigration(string $message = '') : void
1082 {
1083 $tpl = self::initStartUpTemplate('tpl.login_account_migration.html');
1084
1085 $form = new ilPropertyFormGUI();
1086 $form->setFormAction($this->ctrl->getFormAction($this, 'migrateAccount'));
1087
1088 $form->setTitle($this->lng->txt('auth_account_migration'));
1089 $form->addCommandButton('migrateAccount', $this->lng->txt('save'));
1090 $form->addCommandButton('showLogin', $this->lng->txt('cancel'));
1091
1092 $rad = new ilRadioGroupInputGUI($this->lng->txt('auth_account_migration_name'), 'account_migration');
1093 $rad->setValue(1);
1094
1095 $keep = new ilRadioOption(
1096 $this->lng->txt('auth_account_migration_keep'),
1097 static::ACCOUNT_MIGRATION_MIGRATE,
1098 $this->lng->txt('auth_info_migrate')
1099 );
1100 $user = new ilTextInputGUI($this->lng->txt('login'), 'mig_username');
1101 $user->setRequired(true);
1103 (string) ($this->httpRequest->getParsedBody()['mig_username'] ?? '')
1104 ));
1105 $user->setSize(32);
1106 $user->setMaxLength(128);
1107 $keep->addSubItem($user);
1108
1109 $pass = new ilPasswordInputGUI($this->lng->txt('password'), 'mig_password');
1110 $pass->setRetype(false);
1111 $pass->setRequired(true);
1113 (string) ($this->httpRequest->getParsedBody()['mig_password'] ?? '')
1114 ));
1115 $pass->setSize(12);
1116 $pass->setMaxLength(128);
1117 $keep->addSubItem($pass);
1118 $rad->addOption($keep);
1119
1120 $new = new ilRadioOption(
1121 $this->lng->txt('auth_account_migration_new'),
1122 static::ACCOUNT_MIGRATION_NEW,
1123 $this->lng->txt('auth_info_add')
1124 );
1125 $rad->addOption($new);
1126
1127 $form->addItem($rad);
1128
1129 $tpl->setVariable('MIG_FORM', $form->getHTML());
1130
1131 if (strlen($message)) {
1133 }
1134
1136 }
1137
1142 protected function migrateAccount() : bool
1143 {
1144 if (!isset($this->httpRequest->getParsedBody()['account_migration'])) {
1145 $this->showAccountMigration(
1146 $this->lng->txt('select_one')
1147 );
1148 return false;
1149 }
1150
1151 if (
1152 ((int) $this->httpRequest->getParsedBody()['account_migration'] === self::ACCOUNT_MIGRATION_MIGRATE) &&
1153 (
1154 !isset($this->httpRequest->getParsedBody()['mig_username']) ||
1155 !is_string($this->httpRequest->getParsedBody()['mig_username']) ||
1156 0 === strlen($this->httpRequest->getParsedBody()['mig_username']) ||
1157 !isset($this->httpRequest->getParsedBody()['mig_password']) ||
1158 !is_string($this->httpRequest->getParsedBody()['mig_password'])
1159 )
1160 ) {
1161 $this->showAccountMigration(
1162 $this->lng->txt('err_wrong_login')
1163 );
1164 return false;
1165 }
1166
1167 if ((int) $this->httpRequest->getParsedBody()['account_migration'] == self::ACCOUNT_MIGRATION_MIGRATE) {
1168 return $this->doMigration();
1169 } elseif ((int) $this->httpRequest->getParsedBody()['account_migration'] == static::ACCOUNT_MIGRATION_NEW) {
1170 return $this->doMigrationNewAccount();
1171 }
1172 }
1173
1177 protected function doMigrationNewAccount() : bool
1178 {
1179 $credentials = new ilAuthFrontendCredentials();
1180 $credentials->setUsername(ilSession::get(ilAuthFrontend::MIG_EXTERNAL_ACCOUNT));
1181
1182 $provider_factory = new ilAuthProviderFactory();
1183 $provider = $provider_factory->getProviderByAuthMode($credentials, ilSession::get(ilAuthFrontend::MIG_TRIGGER_AUTHMODE));
1184
1185 $this->logger->debug('Using provider: ' . get_class($provider) . ' for further processing.');
1186
1187 $status = ilAuthStatus::getInstance();
1188
1189 $frontend_factory = new ilAuthFrontendFactory();
1190 $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
1191 $frontend = $frontend_factory->getFrontend(
1192 $GLOBALS['DIC']['ilAuthSession'],
1193 $status,
1194 $credentials,
1195 [$provider]
1196 );
1197
1198 if ($frontend->migrateAccountNew()) {
1199 ilInitialisation::redirectToStartingPage();
1200 }
1201
1202 ilUtil::sendFailure($this->lng->txt('err_wrong_login'));
1203 $this->ctrl->redirect($this, 'showAccountMigration');
1204
1205 return true;
1206 }
1207
1211 protected function doMigration() : bool
1212 {
1213 $this->logger->debug('Starting account migration for user: ' . (string) ilSession::get('mig_ext_account'));
1214
1215 $credentials = new ilAuthFrontendCredentials();
1216 $credentials->setUsername((string) $_POST['mig_username']);
1217 $credentials->setPassword((string) $_POST['mig_password']);
1218
1219 $provider_factory = new ilAuthProviderFactory();
1220 $provider = $provider_factory->getProviderByAuthMode($credentials, AUTH_LOCAL);
1221
1222 $status = ilAuthStatus::getInstance();
1223
1224 $frontend_factory = new ilAuthFrontendFactory();
1225 $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
1226 $frontend = $frontend_factory->getFrontend(
1227 $GLOBALS['DIC']['ilAuthSession'],
1228 $status,
1229 $credentials,
1230 array($provider)
1231 );
1232
1233 $frontend->authenticate();
1234
1235 switch ($status->getStatus()) {
1237 $this->getLogger()->debug('Account migration: authentication successful for ' . (string) $_POST['mig_username']);
1238
1239 $provider = $provider_factory->getProviderByAuthMode(
1240 $credentials,
1242 );
1243 $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
1244 $frontend = $frontend_factory->getFrontend(
1245 $GLOBALS['DIC']['ilAuthSession'],
1246 $status,
1247 $credentials,
1248 [$provider]
1249 );
1250 if (
1251 $frontend->migrateAccount($GLOBALS['DIC']['ilAuthSession'])
1252 ) {
1253 ilInitialisation::redirectToStartingPage();
1254 } else {
1255 ilUtil::sendFailure($this->lng->txt('err_wrong_login'), true);
1256 $this->ctrl->redirect($this, 'showAccountMigration');
1257 }
1258 break;
1259
1260 default:
1261 $this->getLogger()->info('Account migration failed for user ' . (string) $_POST['mig_username']);
1262 $this->showAccountMigration($GLOBALS['lng']->txt('err_wrong_login'));
1263 return false;
1264 }
1265 }
1266
1270 protected function showLogout()
1271 {
1272 global $DIC;
1273
1274 $lng = $DIC->language();
1275 $ilIliasIniFile = $DIC['ilIliasIniFile'];
1276
1277 $tpl = self::initStartUpTemplate("tpl.logout.html");
1278
1279 $client_id = $_GET['client_id'];
1280
1281 if (ilPublicSectionSettings::getInstance()->isEnabledForDomain($_SERVER['SERVER_NAME'])) {
1282 $tpl->setCurrentBlock("homelink");
1283 $tpl->setVariable("CLIENT_ID", "?client_id=" . $client_id . "&lang=" . $lng->getLangKey());
1284 $tpl->setVariable("TXT_HOME", $lng->txt("home"));
1285 $tpl->parseCurrentBlock();
1286 }
1287
1288 if ($ilIliasIniFile->readVariable("clients", "list")) {
1289 $tpl->setCurrentBlock("client_list");
1290 $tpl->setVariable("TXT_CLIENT_LIST", $lng->txt("to_client_list"));
1291 $this->ctrl->setParameter($this, "client_id", $client_id);
1292 $tpl->setVariable(
1293 "CMD_CLIENT_LIST",
1294 $this->ctrl->getLinkTarget($this, "showClientList")
1295 );
1296 $tpl->parseCurrentBlock();
1297 $this->ctrl->setParameter($this, "client_id", "");
1298 }
1299
1300 $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("logout"));
1301 $tpl->setVariable("TXT_LOGOUT_TEXT", $lng->txt("logout_text"));
1302 $tpl->setVariable("TXT_LOGIN", $lng->txt("login_to_ilias"));
1303 $tpl->setVariable("CLIENT_ID", "?client_id=" . $client_id . "&cmd=force_login&lang=" . $lng->getLangKey());
1304
1306 }
1307
1308
1309
1313 public function doLogout()
1314 {
1315 global $DIC;
1316
1317 $ilSetting = $DIC->settings();
1318 $user = $DIC->user();
1319 $lng = $DIC->language();
1320 $ilIliasIniFile = $DIC['ilIliasIniFile'];
1321 $ilAppEventHandler = $DIC['ilAppEventHandler'];
1322
1323 $ilAppEventHandler->raise(
1324 'Services/Authentication',
1325 'beforeLogout',
1326 [
1327 'user_id' => $this->user->getId()
1328 ]
1329 );
1330
1331 $user_language = $user->getLanguage();
1332 $had_external_authentication = ilSession::get('used_external_auth');
1333
1335 $GLOBALS['DIC']['ilAuthSession']->logout();
1336
1337 $GLOBALS['ilAppEventHandler']->raise(
1338 'Services/Authentication',
1339 'afterLogout',
1340 array(
1341 'username' => $this->user->getLogin()
1342 )
1343 );
1344
1345 if ((int) $this->user->getAuthMode(true) == AUTH_SAML && $had_external_authentication) {
1346 $this->logger->info('Redirecting user to SAML logout script');
1347 $this->ctrl->redirectToURL('saml.php?action=logout&logout_url=' . urlencode(ILIAS_HTTP_PATH . '/login.php'));
1348 }
1349
1350 // reset cookie
1351 $client_id = $_COOKIE["ilClientId"];
1352 ilUtil::setCookie("ilClientId", "");
1353
1354 // redirect and show logout information
1355 $this->ctrl->setParameter($this, 'client_id', $client_id);
1356 $this->ctrl->setParameter($this, 'lang', $user_language);
1357 $this->ctrl->redirect($this, 'showLogout');
1358 }
1359
1363 public function showClientList()
1364 {
1365 global $tpl, $ilIliasIniFile, $lng;
1366
1367 if (!$ilIliasIniFile->readVariable("clients", "list")) {
1368 $this->processIndexPHP();
1369 return;
1370 }
1371
1372 // fix #21612
1373 $tpl->hideFooter(); // no client yet
1374
1375 $tpl->setVariable("PAGETITLE", $lng->txt("clientlist_clientlist"));
1376
1377 // load client list template
1378 $tpl = self::initStartUpTemplate("tpl.client_list.html");
1379
1380 // load template for table
1381 $tpl->addBlockfile("CLIENT_LIST", "client_list", "tpl.table.html");
1382
1383 // load template for table content data
1384 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
1385
1386 // load table content data
1387 require_once("setup/classes/class.ilClientList.php");
1388 require_once("setup/classes/class.ilClient.php");
1389 require_once("./Services/Table/classes/class.ilTableGUI.php");
1390 $clientlist = new \ilClientList();
1391 $list = $clientlist->getClients();
1392
1393 if (count($list) == 0) {
1394 header("Location: ./setup/setup.php");
1395 exit();
1396 }
1397
1398 $hasPublicSection = false;
1399 foreach ($list as $key => $client) {
1400 $client->setDSN();
1401 if ($client->checkDatabaseExists(true)) {
1402 $client->connect();
1403 if ($client->ini->readVariable("client", "access") and $client->getSetting("setup_ok")) {
1404 $this->ctrl->setParameter($this, "client_id", $key);
1405 $tmp = array();
1406 $tmp[] = $client->getName();
1407 $tmp[] = "<a href=\"" . "login.php?cmd=force_login&client_id=" . urlencode($key) . "\">" . $lng->txt("clientlist_login_page") . "</a>";
1408
1409 if ($client->getSetting('pub_section')) {
1410 $hasPublicSection = true;
1411 $tmp[] = "<a href=\"" . "ilias.php?baseClass=ilRepositoryGUI&client_id=" . urlencode($key) . "\">" . $lng->txt("clientlist_start_page") . "</a>";
1412 } else {
1413 $tmp[] = '';
1414 }
1415
1416 $data[] = $tmp;
1417 }
1418 }
1419 }
1420
1421 // create table
1422 $tbl = new ilTableGUI('', false);
1423
1424 // title & header columns
1425 if ($hasPublicSection) {
1426 $tbl->setTitle($lng->txt("clientlist_available_clients"));
1427 $tbl->setHeaderNames(array($lng->txt("clientlist_installation_name"), $lng->txt("clientlist_login"), $lng->txt("clientlist_public_access")));
1428 $tbl->setHeaderVars(array("name","index","login"));
1429 $tbl->setColumnWidth(array("50%","25%","25%"));
1430 } else {
1431 $tbl->setTitle($lng->txt("clientlist_available_clients"));
1432 $tbl->setHeaderNames(array($lng->txt("clientlist_installation_name"), $lng->txt("clientlist_login"), ''));
1433 $tbl->setHeaderVars(array("name","login",''));
1434 $tbl->setColumnWidth(array("70%","25%",'1px'));
1435 }
1436
1437 // control
1438 $tbl->setOrderColumn($_GET["sort_by"], "name");
1439 $tbl->setOrderDirection($_GET["sort_order"]);
1440 $tbl->setLimit($_GET["limit"]);
1441 $tbl->setOffset($_GET["offset"]);
1442
1443 // content
1444 $tbl->setData($data);
1445
1446 $tbl->disable("icon");
1447 $tbl->disable("numinfo");
1448 $tbl->disable("sort");
1449 $tbl->disable("footer");
1450
1451 // render table
1452 $html_for_nothing = $tbl->render();
1453 self::printToGlobalTemplate($tbl->getTemplateObject());
1454 }
1455
1461 public function showNoCookiesScreen()
1462 {
1463 global $tpl;
1464
1465 $str = "<p style=\"margin:15px;\">
1466 You need to enable Session Cookies in your Browser to use ILIAS.
1467 <br/>
1468 <br/><b>Firefox</b>
1469 <br/>Tools -> Options -> Privacy -> Cookies
1470 <br/>Enable 'Allow sites to set cookies' and activate option 'Keep
1471 <br/>cookies' auf 'until I close Firefox'
1472 <br/>
1473 <br/><b>Mozilla/Netscape</b>
1474 <br/>Edit -> Preferences -> Privacy&Security -> Cookies
1475 <br/>Go to 'Cookie Lifetime Policy' and check option 'Accept for current
1476 <br/>session only'.
1477 <br/>
1478 <br/><b>Internet Explorer</b>
1479 <br/>Tools -> Internet Options -> Privacy -> Advanced
1480 <br/>- Check 'Override automatic cookie handling'
1481 <br/>- Check 'Always allow session cookies'
1482 </p>";
1483 $tpl->setVariable("CONTENT", $str);
1484 $tpl->printToStdout();
1485 }
1486
1490 protected function getAcceptance()
1491 {
1492 $this->showTermsOfService();
1493 }
1494
1498 protected function showTermsOfService()
1499 {
1500 $back_to_login = ('getAcceptance' != $this->ctrl->getCmd());
1501
1502 if (!$this->user->getId()) {
1503 $this->user->setId(ANONYMOUS_USER_ID);
1504 }
1505
1506 $tpl = self::initStartUpTemplate('tpl.view_terms_of_service.html', $back_to_login, !$back_to_login);
1507
1508 $handleDocument = \ilTermsOfServiceHelper::isEnabled() && $this->termsOfServiceEvaluation->hasDocument();
1509 if ($handleDocument) {
1510 $document = $this->termsOfServiceEvaluation->document();
1511 if ('getAcceptance' == $this->ctrl->getCmd()) {
1512 if (isset($_POST['status']) && 'accepted' == $_POST['status']) {
1513 $helper = new \ilTermsOfServiceHelper();
1514
1515 $helper->trackAcceptance($this->user, $document);
1516
1517 if (ilSession::get('orig_request_target')) {
1518 $target = ilSession::get('orig_request_target');
1519 ilSession::set('orig_request_target', '');
1520 ilUtil::redirect($target);
1521 } else {
1522 ilUtil::redirect('index.php?target=' . $_GET['target'] . '&client_id=' . CLIENT_ID);
1523 }
1524 }
1525
1526 $tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, $this->ctrl->getCmd()));
1527 $tpl->setVariable('ACCEPT_CHECKBOX', ilUtil::formCheckbox(0, 'status', 'accepted'));
1528 $tpl->setVariable('ACCEPT_TERMS_OF_SERVICE', $this->lng->txt('accept_usr_agreement'));
1529 $tpl->setVariable('TXT_SUBMIT', $this->lng->txt('submit'));
1530 }
1531
1532 $tpl->setPermanentLink('usr', null, 'agreement');
1533 $tpl->setVariable('TERMS_OF_SERVICE_CONTENT', $document->content());
1534 } else {
1535 $tpl->setVariable(
1536 'TERMS_OF_SERVICE_CONTENT',
1537 sprintf(
1538 $this->lng->txt('no_agreement_description'),
1540 )
1541 );
1542 }
1543
1545 }
1546
1550 protected function processIndexPHP()
1551 {
1552 global $ilIliasIniFile, $ilAuth, $ilSetting;
1553
1554 // In case of an valid session, redirect to starting page
1555 if ($GLOBALS['DIC']['ilAuthSession']->isValid()) {
1556 include_once './Services/Init/classes/class.ilInitialisation.php';
1557 ilInitialisation::redirectToStartingPage();
1558 return;
1559 }
1560
1561 // no valid session => show client list, if no client info is given
1562 if (
1563 !isset($_GET["client_id"]) &&
1564 ($_GET["cmd"] == "") &&
1565 $ilIliasIniFile->readVariable("clients", "list")) {
1566 return $this->showClientList();
1567 }
1568
1569 if (ilPublicSectionSettings::getInstance()->isEnabledForDomain($_SERVER['SERVER_NAME'])) {
1571 }
1572
1573 // otherwise show login page
1574 return $this->showLoginPage();
1575 }
1576
1577
1578 public static function _checkGoto($a_target)
1579 {
1580 global $DIC;
1581 global $objDefinition, $ilPluginAdmin, $ilUser;
1582
1583 $access = $DIC->access();
1584
1585
1586 if (is_object($ilPluginAdmin)) {
1587 // get user interface plugins
1588 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
1589
1590 // search
1591 foreach ($pl_names as $pl) {
1592 $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
1593 $gui_class = $ui_plugin->getUIClassInstance();
1594 $resp = $gui_class->checkGotoHook($a_target);
1595 if ($resp["target"] !== false) {
1596 $a_target = $resp["target"];
1597 break;
1598 }
1599 }
1600 }
1601
1602 if ($a_target == "") {
1603 return false;
1604 }
1605
1606 $t_arr = explode("_", $a_target);
1607 $type = $t_arr[0];
1608
1609 if ($type == "git") {
1610 $type = "glo";
1611 }
1612
1613 if ($type == "pg" | $type == "st") {
1614 $type = "lm";
1615 }
1616
1617 $class = $objDefinition->getClassName($type);
1618 if ($class == "") {
1619 return false;
1620 }
1621
1622 $location = $objDefinition->getLocation($type);
1623 $full_class = "ilObj" . $class . "Access";
1624 include_once($location . "/class." . $full_class . ".php");
1625
1626 $ret = call_user_func(array($full_class, "_checkGoto"), $a_target);
1627
1628 // if no access and repository object => check for parent course/group
1629 if (!$ret &&
1630 !stristr($a_target, "_wsp") &&
1631 $ilUser->getId() != ANONYMOUS_USER_ID && // #10637
1632 !$objDefinition->isAdministrationObject($type) &&
1633 $objDefinition->isRBACObject($type) &&
1634 $t_arr[1]) {
1635 global $tree, $rbacsystem, $ilAccess;
1636
1637 // original type "pg" => pg_<page_id>[_<ref_id>]
1638 if ($t_arr[0] == "pg") {
1639 if (isset($t_arr[2])) {
1640 $ref_id = $t_arr[2];
1641 } else {
1642 $lm_id = ilLMObject::_lookupContObjID($t_arr[1]);
1643 $ref_id = ilObject::_getAllReferences($lm_id);
1644 if ($ref_id) {
1645 $ref_id = array_shift($ref_id);
1646 }
1647 }
1648 } else {
1649 $ref_id = $t_arr[1];
1650 }
1651
1652 include_once "Services/Membership/classes/class.ilParticipants.php";
1653 $block_obj = array();
1654
1655 // walk path to find parent container
1656 $path = $tree->getPathId($ref_id);
1657 array_pop($path);
1658 foreach ($path as $path_ref_id) {
1659 $redirect_infopage = false;
1660 $add_member_role = false;
1661
1662 $ptype = ilObject::_lookupType($path_ref_id, true);
1663 $pobj_id = ilObject::_lookupObjId($path_ref_id);
1664
1665 // core checks: timings/object-specific
1666 if (
1667 !$access->doActivationCheck('read', '', $path_ref_id, $ilUser->getId(), $pobj_id, $ptype) ||
1668 !$access->doStatusCheck('read', '', $path_ref_id, $ilUser->getId(), $pobj_id, $ptype)
1669 ) {
1670 // object in path is inaccessible - aborting
1671 return false;
1672 } elseif ($ptype == "crs") {
1673 // check if already participant
1674 include_once "Modules/Course/classes/class.ilCourseParticipant.php";
1675 $participants = new ilCourseParticipant($pobj_id, $ilUser->getId());
1676 if (!$participants->isAssigned()) {
1677 // subscription currently possible?
1678 include_once "Modules/Course/classes/class.ilObjCourse.php";
1679 if (ilObjCourse::_isActivated($pobj_id) &&
1681 $block_obj[] = $path_ref_id;
1682 $add_member_role = true;
1683 } else {
1684 $redirect_infopage = true;
1685 }
1686 }
1687 } elseif ($ptype == "grp") {
1688 // check if already participant
1689 include_once "Modules/Group/classes/class.ilGroupParticipants.php";
1690 if (!ilGroupParticipants::_isParticipant($path_ref_id, $ilUser->getId())) {
1691 // subscription currently possible?
1692 include_once "Modules/Group/classes/class.ilObjGroup.php";
1693 $group_obj = new ilObjGroup($path_ref_id);
1694 if ($group_obj->isRegistrationEnabled()) {
1695 $block_obj[] = $path_ref_id;
1696 $add_member_role = true;
1697 } else {
1698 $redirect_infopage = true;
1699 }
1700 }
1701 }
1702
1703 // add members roles for all "blocking" objects
1704 if ($add_member_role) {
1705 // cannot join? goto will never work, so redirect to current object
1706 $rbacsystem->resetPACache($ilUser->getId(), $path_ref_id);
1707 if (!$rbacsystem->checkAccess("join", $path_ref_id)) {
1708 $redirect_infopage = true;
1709 } else {
1710 $rbacsystem->addTemporaryRole(
1711 $ilUser->getId(),
1713 );
1714 }
1715 }
1716
1717 // redirect to infopage of 1st blocking object in path
1718 if ($redirect_infopage) {
1719 if ($rbacsystem->checkAccess("visible", $path_ref_id)) {
1720 ilUtil::redirect("ilias.php?baseClass=ilRepositoryGUI" .
1721 "&ref_id=" . $path_ref_id . "&cmd=infoScreen");
1722 } else {
1723 return false;
1724 }
1725 }
1726 }
1727
1728
1729 // check if access will be possible with all (possible) member roles added
1730 $rbacsystem->resetPACache($ilUser->getId(), $ref_id);
1731 if ($rbacsystem->checkAccess("read", $ref_id) && sizeof($block_obj)) { // #12128
1732 // this won't work with lm-pages (see above)
1733 // include_once "Services/Link/classes/class.ilLink.php";
1734 // $_SESSION["pending_goto"] = ilLink::_getStaticLink($ref_id, $type);
1735
1736 // keep original target
1737 $_SESSION["pending_goto"] = "goto.php?target=" . $a_target;
1738
1739 // redirect to 1st non-member object in path
1740 ilUtil::redirect("ilias.php?baseClass=ilRepositoryGUI" .
1741 "&ref_id=" . array_shift($block_obj));
1742 }
1743 }
1744
1745 return $ret;
1746 }
1747
1748 public function confirmRegistration()
1749 {
1750 ilUtil::setCookie('iltest', 'cookie', false);
1751
1752 if (!isset($_GET['rh']) || !strlen(trim($_GET['rh']))) {
1753 $this->ctrl->redirectToURL('./login.php?cmd=force_login&reg_confirmation_msg=reg_confirmation_hash_not_passed');
1754 }
1755
1756 try {
1757 $oRegSettings = new ilRegistrationSettings();
1758
1759 $usr_id = ilObjUser::_verifyRegistrationHash(trim($_GET['rh']));
1762 $user->setActive(true);
1763 $password = '';
1764 if ($oRegSettings->passwordGenerationEnabled()) {
1765 $passwords = ilUtil::generatePasswords(1);
1766 $password = $passwords[0];
1767 $user->setPasswd($password, IL_PASSWD_PLAIN);
1768 $user->setLastPasswordChangeTS(time());
1769 }
1770 $user->update();
1771
1772 $target = $user->getPref('reg_target');
1773 if (strlen($target) > 0) {
1774 // Used for ilAccountMail in ilAccountRegistrationMail, which relies on this super global ...
1775 $_GET['target'] = $target;
1776 }
1777
1778 $accountMail = new ilAccountRegistrationMail(
1779 $oRegSettings,
1780 $this->lng,
1782 );
1783 $accountMail->withEmailConfirmationRegistrationMode()->send($user, $password);
1784
1785 $this->ctrl->redirectToURL(sprintf(
1786 './login.php?cmd=force_login&reg_confirmation_msg=reg_account_confirmation_successful&lang=%s',
1787 $user->getLanguage()
1788 ));
1789 } catch (ilRegConfirmationLinkExpiredException $exception) {
1790 $soap_client = new ilSoapClient();
1791 $soap_client->setResponseTimeout(1);
1792 $soap_client->enableWSDL(true);
1793 $soap_client->init();
1794
1795 $this->logger->info('Triggered soap call (background process) for deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
1796
1797 $soap_client->call(
1798 'deleteExpiredDualOptInUserObjects',
1799 [
1800 $_COOKIE[session_name()] . '::' . $_COOKIE['ilClientId'],
1801 $exception->getCode() // user id
1802 ]
1803 );
1804
1805 $this->ctrl->redirectToURL(sprintf(
1806 './login.php?cmd=force_login&reg_confirmation_msg=%s',
1807 $exception->getMessage()
1808 ));
1809 } catch (ilRegistrationHashNotFoundException $exception) {
1810 $this->ctrl->redirectToURL(sprintf(
1811 './login.php?cmd=force_login&reg_confirmation_msg=%s',
1812 $exception->getMessage()
1813 ));
1814 }
1815 }
1816
1823 public static function initStartUpTemplate($a_tmpl, $a_show_back = false, $a_show_logout = false)
1824 {
1832 global $lng, $ilAccess, $ilSetting;
1833 $tpl = new ilGlobalTemplate("tpl.main.html", true, true);
1834
1835 $tpl->addBlockfile('CONTENT', 'content', 'tpl.startup_screen.html', 'Services/Init');
1836
1837 $view_title = $lng->txt('login_to_ilias');
1838 if ($a_show_back) {
1839 // #13400
1840 $param = 'client_id=' . $_COOKIE['ilClientId'] . '&lang=' . $lng->getLangKey();
1841
1842 $tpl->setCurrentBlock('link_item_bl');
1843 $tpl->setVariable('LINK_TXT', $view_title);
1844 $tpl->setVariable('LINK_URL', 'login.php?cmd=force_login&' . $param);
1845 $tpl->parseCurrentBlock();
1846
1847 include_once './Services/Init/classes/class.ilPublicSectionSettings.php';
1848 if (ilPublicSectionSettings::getInstance()->isEnabledForDomain($_SERVER['SERVER_NAME']) &&
1849 $ilAccess->checkAccessOfUser(ANONYMOUS_USER_ID, 'read', '', ROOT_FOLDER_ID)) {
1850 $tpl->setVariable('LINK_URL', 'index.php?' . $param);
1851 $tpl->setVariable('LINK_TXT', $lng->txt('home'));
1852 $tpl->parseCurrentBlock();
1853 }
1854 } elseif ($a_show_logout) {
1855 $view_title = $lng->txt('logout');
1856 $tpl->setCurrentBlock('link_item_bl');
1857 $tpl->setVariable('LINK_TXT', $view_title);
1858 $tpl->setVariable('LINK_URL', ILIAS_HTTP_PATH . '/logout.php');
1859 $tpl->parseCurrentBlock();
1860 }
1861
1862 if (is_array($a_tmpl)) {
1863 $template_file = $a_tmpl[0];
1864 $template_dir = $a_tmpl[1];
1865 } else {
1866 $template_file = $a_tmpl;
1867 $template_dir = 'Services/Init';
1868 }
1869
1870 $tpl->addBlockFile('STARTUP_CONTENT', 'startup_content', $template_file, $template_dir);
1871
1872 PageContentProvider::setViewTitle($view_title);
1873 $short_title = $ilSetting->get('short_inst_name');
1874 if (trim($short_title) === "") {
1875 $short_title = 'ILIAS';
1876 }
1877 PageContentProvider::setShortTitle($short_title);
1878
1879 $header_title = (string) ilObjSystemFolder::_getHeaderTitle();
1880 PageContentProvider::setTitle($header_title);
1881
1882 return $tpl;
1883 }
1884
1889 protected function showSamlLoginForm($page_editor_html)
1890 {
1891 require_once 'Services/Saml/classes/class.ilSamlIdp.php';
1892 require_once 'Services/Saml/classes/class.ilSamlSettings.php';
1893
1894 if (count(ilSamlIdp::getActiveIdpList()) > 0 && ilSamlSettings::getInstance()->isDisplayedOnLoginPage()) {
1895 $tpl = new ilTemplate('tpl.login_form_saml.html', true, true, 'Services/Saml');
1896
1897 $return = '';
1898 if (isset($_GET['target'])) {
1899 $return = '?returnTo=' . urlencode(ilUtil::stripSlashes($_GET['target']));
1900 }
1901
1902 $tpl->setVariable('SAML_SCRIPT_URL', './saml.php' . $return);
1903 $tpl->setVariable('TXT_LOGIN', $GLOBALS['DIC']->language()->txt('saml_log_in'));
1904 $tpl->setVariable('LOGIN_TO_ILIAS_VIA_SAML', $GLOBALS['DIC']->language()->txt('login_to_ilias_via_saml'));
1905 $tpl->setVariable('TXT_SAML_LOGIN_TXT', $GLOBALS['DIC']->language()->txt('saml_login_form_txt'));
1906 $tpl->setVariable('TXT_SAML_LOGIN_INFO_TXT', $GLOBALS['DIC']->language()->txt('saml_login_form_info_txt'));
1907
1908 return $this->substituteLoginPageElements(
1909 $GLOBALS['tpl'],
1910 $page_editor_html,
1911 $tpl->get(),
1912 '[list-saml-login]',
1913 'SAML_LOGIN_FORM'
1914 );
1915 }
1916
1917 return $page_editor_html;
1918 }
1919
1924 protected function showOpenIdConnectLoginForm($page_editor_html)
1925 {
1926 global $DIC;
1927
1928 $lang = $DIC->language();
1929
1930 $oidc_settings = ilOpenIdConnectSettings::getInstance();
1931 if ($oidc_settings->getActive()) {
1932 $tpl = new ilTemplate('tpl.login_element.html', true, true, 'Services/OpenIdConnect');
1933
1934 $lang->loadLanguageModule('auth');
1935 $tpl->setVariable('TXT_OIDCONNECT_HEADER', $lang->txt('auth_oidc_login_element_info'));
1936
1937 $target = empty($_GET['target']) ? '' : ('?target=' . (string) $_GET['target']);
1938 switch ($oidc_settings->getLoginElementType()) {
1940
1941
1942 $tpl->setVariable('SCRIPT_OIDCONNECT_T', ILIAS_HTTP_PATH . '/openidconnect.php' . $target);
1943 $tpl->setVariable('TXT_OIDC', $oidc_settings->getLoginElemenText());
1944 break;
1945
1947 $tpl->setVariable('SCRIPT_OIDCONNECT_I', ILIAS_HTTP_PATH . '/openidconnect.php' . $target);
1948 $tpl->setVariable('IMG_SOURCE', $oidc_settings->getImageFilePath());
1949 break;
1950 }
1951
1952 return $this->substituteLoginPageElements(
1953 $GLOBALS['tpl'],
1954 $page_editor_html,
1955 $tpl->get(),
1956 '[list-openid-connect-login]',
1957 'OPEN_ID_CONNECT_LOGIN_FORM'
1958 );
1959 }
1960
1961 return $page_editor_html;
1962 }
1963
1968 {
1969 global $DIC;
1970
1971 $this->getLogger()->debug('Trying openid connect authentication');
1972
1973 $credentials = new ilAuthFrontendCredentialsOpenIdConnect();
1974 $credentials->initFromRequest();
1975
1976 $provider_factory = new ilAuthProviderFactory();
1977 $provider = $provider_factory->getProviderByAuthMode($credentials, AUTH_OPENID_CONNECT);
1978
1979 $status = ilAuthStatus::getInstance();
1980
1981 $frontend_factory = new ilAuthFrontendFactory();
1982 $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
1983 $frontend = $frontend_factory->getFrontend(
1984 $GLOBALS['DIC']['ilAuthSession'],
1985 $status,
1986 $credentials,
1987 array($provider)
1988 );
1989
1990 $frontend->authenticate();
1991
1992 switch ($status->getStatus()) {
1994 ilLoggerFactory::getLogger('auth')->debug('Authentication successful; Redirecting to starting page.');
1995 include_once './Services/Init/classes/class.ilInitialisation.php';
1996 ilInitialisation::redirectToStartingPage();
1997 return;
1998
2000 ilUtil::sendFailure($status->getTranslatedReason(), true);
2001 $GLOBALS['ilCtrl']->redirect($this, 'showLoginPage');
2002 return false;
2003 }
2004
2005 ilUtil::sendFailure($this->lng->txt('err_wrong_login'));
2006 $this->showLoginPage();
2007 return false;
2008 }
2009
2010
2014 protected function doSamlAuthentication()
2015 {
2016 global $DIC;
2017
2018 $this->getLogger()->debug('Trying saml authentication');
2019
2020 $request = $DIC->http()->request();
2021 $params = $request->getQueryParams();
2022
2024 $auth = $factory->auth();
2025
2026 if (isset($params['action']) && $params['action'] == 'logout') {
2027 $logout_url = isset($params['logout_url']) ? $params['logout_url'] : '';
2028 ilLoggerFactory::getLogger('auth')->info(sprintf('Requested SAML logout: %s', $logout_url));
2029 $auth->logout($logout_url);
2030 }
2031
2032 if (isset($params['target']) && !isset($params['returnTo'])) {
2033 $params['returnTo'] = $params['target'];
2034 }
2035 if (isset($params['returnTo'])) {
2036 $auth->storeParam('target', $params['returnTo']);
2037 }
2038
2039 ilLoggerFactory::getLogger('auth')->debug('Started SAML authentication request');
2040
2041 if (!$auth->isAuthenticated()) {
2042 ilLoggerFactory::getLogger('auth')->debug('User is not authenticated, yet');
2043 if (!isset($_GET['idpentityid']) || !isset($_GET['saml_idp_id'])) {
2044 $activeIdps = ilSamlIdp::getActiveIdpList();
2045 if (1 == count($activeIdps)) {
2046 $idp = current($activeIdps);
2047 $_GET['idpentityid'] = $idp->getEntityId();
2048 $_GET['saml_idp_id'] = $idp->getIdpId();
2049
2050 ilLoggerFactory::getLogger('auth')->debug(sprintf(
2051 'Found exactly one active IDP with id %s: %s',
2052 $idp->getIdpId(),
2053 $idp->getEntityId()
2054 ));
2055 } elseif (0 == count($activeIdps)) {
2056 ilLoggerFactory::getLogger('auth')->debug('Did not find any active IDP, skipp authentication process');
2057 $GLOBALS['DIC']->ctrl()->redirect($this, 'showLoginPage');
2058 } else {
2059 ilLoggerFactory::getLogger('auth')->debug('Found multiple active IPDs, presenting IDP selection...');
2060 $this->showSamlIdpSelection($auth, $activeIdps);
2061 return;
2062 }
2063 }
2064
2065 $auth->storeParam('idpId', (int) $_GET['saml_idp_id']);
2066 ilLoggerFactory::getLogger('auth')->debug(sprintf(
2067 'Stored relevant IDP id in session: %s',
2068 (string) $auth->getParam('idpId')
2069 ));
2070 }
2071
2072 // re-init
2073 $auth = $factory->auth();
2074
2075 ilLoggerFactory::getLogger('auth')->debug('Checking SAML authentication status...');
2076
2077 $auth->protectResource();
2078
2079 ilLoggerFactory::getLogger('auth')->debug(
2080 'SAML authentication successful, continuing with ILIAS internal authentication process...'
2081 );
2082
2083 $idpId = (int) $auth->getParam('idpId');
2084
2085 ilLoggerFactory::getLogger('auth')->debug(sprintf(
2086 'Internal SAML IDP id fetched from session: %s',
2087 (string) $idpId
2088 ));
2089
2090 if ($idpId < 1) {
2091 ilLoggerFactory::getLogger('auth')->debug(
2092 'No valid internal IDP id found (most probably due to IDP initiated SSO), trying fallback determination...'
2093 );
2094 $authData = $auth->getAuthDataArray();
2095 if (isset($authData['saml:sp:IdP'])) {
2096 $idpId = ilSamlIdp::geIdpIdByEntityId($authData['saml:sp:IdP']);
2097 ilLoggerFactory::getLogger('auth')->debug(sprintf(
2098 'Searching active ILIAS IDP by entity id "%s" results in: %s',
2099 $authData['saml:sp:IdP'],
2100 (string) $idpId
2101 ));
2102 } else {
2103 ilLoggerFactory::getLogger('auth')->debug(
2104 'Could not execute fallback determination, no IDP entity ID found SAML authentication session data'
2105 );
2106 }
2107 }
2108 $_GET['target'] = $auth->popParam('target');
2109
2110 $_POST['auth_mode'] = AUTH_SAML . '_' . $idpId;
2111
2112 $credentials = new ilAuthFrontendCredentialsSaml($auth);
2113 $credentials->initFromRequest();
2114
2115 $provider_factory = new ilAuthProviderFactory();
2116 $provider = $provider_factory->getProviderByAuthMode($credentials, ilUtil::stripSlashes($_POST['auth_mode']));
2117
2118 $status = ilAuthStatus::getInstance();
2119
2120 $frontend_factory = new ilAuthFrontendFactory();
2121 $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
2122 $frontend = $frontend_factory->getFrontend(
2123 $GLOBALS['DIC']['ilAuthSession'],
2124 $status,
2125 $credentials,
2126 array($provider)
2127 );
2128
2129 $frontend->authenticate();
2130
2131 switch ($status->getStatus()) {
2133 ilLoggerFactory::getLogger('auth')->debug('Authentication successful; Redirecting to starting page.');
2134 return ilInitialisation::redirectToStartingPage();
2135
2137 return $GLOBALS['DIC']->ctrl()->redirect($this, 'showAccountMigration');
2138
2140 ilUtil::sendFailure($status->getTranslatedReason(), true);
2141 $GLOBALS['DIC']->ctrl()->redirect($this, 'showLoginPage');
2142 return false;
2143 }
2144
2145 ilUtil::sendFailure($this->lng->txt('err_wrong_login'));
2146 $this->showLoginPage();
2147
2148 return false;
2149 }
2150
2155 protected function showSamlIdpSelection(\ilSamlAuth $auth, array $idps)
2156 {
2157 global $DIC;
2158
2159 self::initStartUpTemplate(array('tpl.saml_idp_selection.html', 'Services/Saml'));
2160
2161 $factory = $DIC->ui()->factory();
2162 $renderer = $DIC->ui()->renderer();
2163
2164 $DIC->ctrl()->setTargetScript('saml.php');
2165
2166 $items = [];
2167
2168 $table = new ilSamlIdpSelectionTableGUI($this, 'doSamlAuthentication');
2169
2170 foreach ($idps as $idp) {
2171 $DIC->ctrl()->setParameter($this, 'saml_idp_id', $idp->getIdpId());
2172 $DIC->ctrl()->setParameter($this, 'idpentityid', urlencode($idp->getEntityId()));
2173
2174 $items[] = [
2175 'idp_link' => $renderer->render($factory->link()->standard($idp->getEntityId(), $DIC->ctrl()->getLinkTarget($this, 'doSamlAuthentication')))
2176 ];
2177 }
2178
2179 $table->setData($items);
2180 $this->mainTemplate->setVariable('CONTENT', $table->getHtml());
2181
2182 $this->mainTemplate->printToStdout('DEFAULT', false);
2183 }
2184}
user()
Definition: user.php:4
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$location
Definition: buildRTE.php:44
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
Class ilPageContentProvider.
Class ShibbolethWAYF.
const AUTH_SHIBBOLETH
const AUTH_APACHE
const AUTH_OPENID_CONNECT
const AUTH_SAML
const AUTH_LOCAL
const AUTH_CAS
const AUTH_PROVIDER_LTI
const IL_COMP_SERVICE
const IL_PASSWD_PLAIN
static isUnusedCode($code)
static getCodeValidUntil($code)
static applyRoleAssignments(ilObjUser $user, $code)
static applyAccessLimits(ilObjUser $user, $code)
static useCode($code)
Class ilAccountRegistrationGUI.
Class ilAccountRegistrationMail.
Auth frontend credentials for CAS auth.
Auth credentials for lti oauth based authentication.
Class ilAuthFrontendCredentialsSaml.
Factory for auth frontend classes.
const STATUS_CODE_ACTIVATION_REQUIRED
static getInstance()
Get status instance.
const STATUS_AUTHENTICATION_FAILED
const STATUS_ACCOUNT_MIGRATION_REQUIRED
static _getMultipleAuthModeOptions($lng)
static _hasMultipleAuthenticationMethods()
This class represents a captcha input in a property form.
special template class to simplify handling of ITX/PEAR
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.
This class represents a hidden form property in a property form.
static goToPublicSection()
go to public section
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
static lookupId($a_lang_key)
Lookup obj_id of language @global ilDB $ilDB.
static getLogger($a_component_id)
Get component logger.
Login page GUI class.
static _registrationEnabled($a_obj_id)
Registration enabled? Method is in Access class, since it is needed by Access/ListGUI.
static _isActivated($a_obj_id)
Is activated.
Class ilObjGroup.
static getSyntaxStylePath()
get syntax style path
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
static _verifyRegistrationHash($a_hash)
Verifies a registration hash.
static _lookupLogin($a_user_id)
lookup login
static _lookupId($a_user_str)
Lookup id by login.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupObjId($a_id)
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
static getInstance()
Get singleton instance.
static _existsAndNotEmpty($a_parent_type, $a_id, $a_lang="-")
checks whether page exists and is not empty (may return true on some empty pages)
static getDefaultMemberRole($a_ref_id)
Password assistance facility for users who have forgotten their password or for users for whom no pas...
This class represents a password property in a property form.
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get Plugin Object.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
Class for user related exception handling in ILIAS.
Class for user related exception handling in ILIAS.
Class ilObjAuthSettingsGUI.
Class ilSamlAuthFactory.
Class ilSamlIdpSelectionTableGUI.
static getActiveIdpList()
static geIdpIdByEntityId($entityId)
const SESSION_CLOSE_USER
static set($a_var, $a_val)
Set a value.
static setClosingContext($a_context)
set closing context (for statistics)
static get($a_var)
Get a value.
ILIAS Setting Class.
StartUp GUI class.
processIndexPHP()
process index.php
showLoginInformation($page_editor_html, $tpl)
Show login information.
showShibbolethLoginForm($page_editor_html)
Show shibboleth login form.
showLoginPage(ilPropertyFormGUI $form=null)
showCASLoginForm($page_editor_html)
Show cas login @global ilSetting $ilSetting.
showAccountMigration(string $message='')
Show account migration screen.
static _checkGoto($a_target)
doStandardAuthentication()
Check form input; authenticate user.
getAcceptance()
Get terms of service.
doApacheAuthentication()
Try apache auth.
showCodeForm($a_username=null, $a_form=null)
doOpenIdConnectAuthentication()
do open id connect authentication
__construct(\ilObjUser $user=null, \ilTermsOfServiceDocumentEvaluation $termsOfServiceEvaluation=null, \ilGlobalTemplate $mainTemplate=null, ServerRequestInterface $httpRequest=null)
ilStartUpGUI constructor.
const ACCOUNT_MIGRATION_MIGRATE
purgePlaceholders($page_editor_html)
Purge page editor html from unused placeholders.
initStandardLoginForm()
Initialize the standard.
doShibbolethAuthentication()
Trying shibboleth authentication.
getLogger()
Get logger.
migrateAccount()
Migrate Account.
static printToGlobalTemplate($tpl)
substituteLoginPageElements($tpl, $page_editor_html, $element_html, $placeholder, $fallback_tplvar)
Substitute login page elements.
showClientList()
show client list
jumpToPasswordAssistance()
jump to password assistance
showLogout()
Show logout screen.
showSamlIdpSelection(\ilSamlAuth $auth, array $idps)
doLTIAuthentication()
Handle lti requests.
jumpToRegistration()
jump to registration gui
showLoginForm($page_editor_html, ilPropertyFormGUI $form=null)
Show login form @global ilSetting $ilSetting.
executeCommand()
execute command
getLoginPageEditorHTML()
Get HTML of ILIAS login page editor.
initCodeForm($a_username)
showTermsOfService()
Show terms of service.
doLogout()
show logout screen
doCasAuthentication()
Try CAS auth.
showNoCookiesScreen()
show help screen, if cookies are disabled
showOpenIdConnectLoginForm($page_editor_html)
showRegistrationLinks($page_editor_html)
Show registration, password forgotten, client slection links @global ilLanguage $lng @global ilSettin...
showTermsOfServiceLink(string $page_editor_html)
Show terms of service link.
showSamlLoginForm($page_editor_html)
static getMailsToAddress()
Get mailto: emails.
Class ilTableGUI.
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
static formCheckbox($checked, $varname, $value, $disabled=false)
??? @access public
static setCookie($a_cookie_name, $a_cookie_value='', $a_also_set_super_global=true, $a_set_cookie_invalid=false)
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static generatePasswords($a_number)
Generate a number of passwords.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$password
Definition: cron.php:14
if($_SERVER['argc']< 4) $client
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
$client_id
Interface ilSamlAuth.
Interface ilTermsOfServiceDocumentEvaluation.
language()
Definition: language.php:2
exit
Definition: login.php:29
$factory
Definition: metadata.php:58
$auth
Definition: metadata.php:59
static http()
Fetches the global http state from ILIAS.
$ret
Definition: parser.php:6
global $ilSetting
Definition: privfeed.php:17
$type
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$data
Definition: storeScorm.php:23
$ilIliasIniFile
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
$ilUser
Definition: imgupload.php:18
$lang
Definition: xapiexit.php:8
$message
Definition: xapiexit.php:14
$DIC
Definition: xapitoken.php:46
$_COOKIE[session_name()]
Definition: xapitoken.php:39
$param
Definition: xapitoken.php:31