ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAuthFrontendHTTP.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
26  private ilLogger $logger;
27 
29  {
30  parent::__construct($session, $status, $credentials, $providers);
31 
32  global $DIC;
33  $this->logger = $DIC->logger()->auth();
34  }
35 
36  public function authenticate(): bool
37  {
38  foreach ($this->getProviders() as $provider) {
39  $this->resetStatus();
40 
41  $this->logger->debug('Trying authentication against: ' . get_class($provider));
42 
43  $provider->doAuthentication($this->getStatus());
44 
45  $this->logger->debug('Authentication user id: ' . $this->getStatus()
46  ->getAuthenticatedUserId());
47 
48  switch ($this->getStatus()->getStatus()) {
50  return $this->handleAuthenticationSuccess($provider);
51 
53  $this->logger->notice("Account migration required.");
54  break;
55 
57  default:
58  $this->logger->debug('Authentication failed against: ' . get_class($provider));
59  break;
60  }
61  }
62  return $this->handleAuthenticationFail();
63  }
64 
68  protected function handleAuthenticationFail(): bool
69  {
70  header("WWW-Authenticate: Basic realm=\"" . CLIENT_ID . "\"");
71  header('HTTP/1.0 401 Unauthorized');
72  return false;
73  }
74 }
getProviders()
Get providers.
Interface of auth credentials.
const STATUS_AUTHENTICATION_FAILED
handleAuthenticationSuccess(ilAuthProviderInterface $provider)
Handle successful authentication.
$session
resetStatus()
Reset status.
__construct(ilAuthSession $session, ilAuthStatus $status, ilAuthCredentials $credentials, array $providers)
global $DIC
Definition: feed.php:28
$provider
Definition: ltitoken.php:83
Interface for auth methods (web form, http, ...)
authenticate()
Try authentication.
const CLIENT_ID
Definition: constants.php:41
handleAuthenticationFail()
Draw basic auth.
ilAuthCredentials $credentials
__construct(Container $dic, ilPlugin $plugin)
Auth status implementation.
const STATUS_ACCOUNT_MIGRATION_REQUIRED