ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilAuthFrontendHTTP.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  private ilLogger $logger;
24 
28  public function __construct(
29  ilAuthSession $session,
32  array $providers
33  ) {
34  parent::__construct($session, $status, $credentials, $providers);
35 
36  global $DIC;
37  $this->logger = $DIC->logger()->auth();
38  }
39 
40  public function authenticate(): bool
41  {
42  foreach ($this->getProviders() as $provider) {
43  $this->resetStatus();
44 
45  $this->logger->debug('Trying authentication against: ' . get_class($provider));
46 
47  $provider->doAuthentication($this->getStatus());
48 
49  $this->logger->debug('Authentication user id: ' . $this->getStatus()
50  ->getAuthenticatedUserId());
51 
52  switch ($this->getStatus()->getStatus()) {
54  return $this->handleAuthenticationSuccess($provider);
55 
57  $this->logger->notice('Account migration required.');
58  break;
59 
61  default:
62  $this->logger->debug('Authentication failed against: ' . get_class($provider));
63  break;
64  }
65  }
66  return $this->handleAuthenticationFail();
67  }
68 
69  protected function handleAuthenticationFail(): bool
70  {
71  parent::handleAuthenticationFail();
72 
73  header('WWW-Authenticate: Basic realm="' . CLIENT_ID . '"');
74  header('HTTP/1.0 401 Unauthorized');
75  return false;
76  }
77 }
handleAuthenticationSuccess(ilAuthProviderInterface $provider)
const int STATUS_AUTHENTICATED
__construct(ilAuthSession $session, ilAuthStatus $status, ilAuthCredentials $credentials, array $providers)
$provider
Definition: ltitoken.php:80
const CLIENT_ID
Definition: constants.php:41
global $DIC
Definition: shib_login.php:26
const int STATUS_AUTHENTICATION_FAILED
ilAuthCredentials $credentials
__construct(Container $dic, ilPlugin $plugin)
header()
expected output: > ILIAS shows the rendered Component.
Definition: header.php:29
const int STATUS_ACCOUNT_MIGRATION_REQUIRED