ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
LoginPerformer.php
Go to the documentation of this file.
1 <?php
2 
20 
21 use ilLogger;
22 use ilCtrlInterface;
24 use ilLanguage;
25 use ilAuthSession;
28 use ilAuthUtils;
29 use ilAuthStatus;
31 use ilException;
33 use ilStartUpGUI;
34 
39 {
40  public function __construct(
41  private ilLogger $logger,
42  private ilCtrlInterface $ctrl,
43  private ilGlobalTemplateInterface $template,
44  private ilLanguage $lng,
45  private ilAuthSession $auth_ession,
46  ) {
47  }
48 
49  public function doShibbolethAuthentication(): void
50  {
51  $this->logger->debug('Trying shibboleth authentication');
52 
53  $credentials = new ilAuthFrontendCredentialsShibboleth();
54  $credentials->initFromRequest();
55 
56  $provider_factory = new ilAuthProviderFactory();
57  $provider = $provider_factory->getProviderByAuthMode($credentials, ilAuthUtils::AUTH_SHIBBOLETH);
58 
59  $status = ilAuthStatus::getInstance();
60 
61  $frontend_factory = new ilAuthFrontendFactory();
62  $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
63  $frontend = $frontend_factory->getFrontend(
64  $this->auth_ession,
65  $status,
66  $credentials,
67  [$provider]
68  ) ?? throw new ilException('No frontend found');
69  $frontend->authenticate();
70 
71  switch ($status->getStatus()) {
73  $this->logger->debug('Authentication successful; Redirecting to starting page.');
75 
76  // no break
78  $this->ctrl->redirect($this, 'showAccountMigration');
79 
80  // no break
82  $this->template->setOnScreenMessage('failure', $status->getTranslatedReason(), true);
83  $this->ctrl->redirect($this, 'showLoginPage');
84  }
85 
86  $this->template->setOnScreenMessage('failure', $this->lng->txt('err_wrong_login'), true);
87  $this->ctrl->setTargetScript('ilias.php');
88  $this->ctrl->redirectByClass(ilStartUpGUI::class, 'showLoginPage');
89  }
90 }
const int AUTH_SHIBBOLETH
const int STATUS_AUTHENTICATED
__construct(private ilLogger $logger, private ilCtrlInterface $ctrl, private ilGlobalTemplateInterface $template, private ilLanguage $lng, private ilAuthSession $auth_ession,)
$provider
Definition: ltitoken.php:80
const int STATUS_AUTHENTICATION_FAILED
const int CONTEXT_STANDARD_FORM
Authentication with id and password.
static redirectToStartingPage(string $target='')
static getInstance()
Get status instance.
global $lng
Definition: privfeed.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const int STATUS_ACCOUNT_MIGRATION_REQUIRED