ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAuthProviderFactory.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
28 {
29  private ilLogger $logger;
30 
34  public function __construct()
35  {
36  global $DIC;
37  $this->logger = $DIC->logger()->auth();
38  }
39 
43  public function getProviders(ilAuthCredentials $credentials): array
44  {
45  // Fixed provider selection;
46  if ($credentials->getAuthMode() !== '') {
47  $this->logger->debug('Returning fixed provider for auth mode: ' . $credentials->getAuthMode());
48  return array(
49  $this->getProviderByAuthMode($credentials, $credentials->getAuthMode())
50  );
51  }
52 
53  $auth_determination = ilAuthModeDetermination::_getInstance();
54  $sequence = $auth_determination->getAuthModeSequence($credentials->getUsername());
55 
56  $providers = array();
57  foreach ($sequence as $position => $authmode) {
58  $provider = $this->getProviderByAuthMode($credentials, (string) $authmode);
59  if ($provider instanceof ilAuthProviderInterface) {
60  $providers[] = $provider;
61  }
62  }
63  return $providers;
64  }
65 
69  public function getProviderByAuthMode(ilAuthCredentials $credentials, $a_authmode): ?ilAuthProviderInterface
70  {
71  switch ((int) $a_authmode) {
73  $ldap_info = explode('_', $a_authmode);
74  $this->logger->debug('Using ldap authentication with credentials ');
75  return new ilAuthProviderLDAP($credentials, (int) $ldap_info[1]);
76 
78  $this->logger->debug('Using local database authentication');
79  return new ilAuthProviderDatabase($credentials);
80 
82  $this->logger->debug('Using SOAP authentication.');
83  return new ilAuthProviderSoap($credentials);
84 
86  $this->logger->debug('Using apache authentication.');
87  return new ilAuthProviderApache($credentials);
88 
90  $this->logger->debug('Using CAS authentication');
91  return new ilAuthProviderCAS($credentials);
92 
94  $this->logger->debug('Using shibboleth authentication.');
95  return new ilAuthProviderShibboleth($credentials);
96 
98  $this->logger->debug('Using lti provider authentication.');
99  return new ilAuthProviderLTI($credentials);
100 
102  $this->logger->debug('Using ecs authentication.');
103  return new ilAuthProviderECS($credentials);
104 
106  $this->logger->debug('Using apache authentication.');
107  return new ilAuthProviderSaml($credentials, ilSamlIdp::getIdpIdByAuthMode($a_authmode));
108 
110  $this->logger->debug('Using openid connect authentication.');
111  return new ilAuthProviderOpenIdConnect($credentials);
112 
113  default:
114  $this->logger->debug('Plugin authentication: ' . $a_authmode);
115  foreach (ilAuthUtils::getAuthPlugins() as $pl) {
116  $provider = $pl->getProvider($credentials, $a_authmode);
117  if ($provider instanceof ilAuthProviderInterface) {
118  return $provider;
119  }
120  }
121  break;
122  }
123  return null;
124  }
125 }
const AUTH_OPENID_CONNECT
getProviders(ilAuthCredentials $credentials)
Get provider.
Interface of auth credentials.
CAS authentication provider.
Class ilAuthProviderSoap.
getUsername()
Get username.
static getIdpIdByAuthMode(string $a_auth_mode)
global $DIC
Definition: feed.php:28
static getAuthPlugins()
Get active enabled auth plugins.
$provider
Definition: ltitoken.php:83
Standard interface for auth provider implementations.
Auth prvider for ecs auth.
Class ilAuthProviderOpenIdConnect.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilAuthProviderSaml.
Shibboleth authentication provider.
getAuthMode()
Get auth mode.
getProviderByAuthMode(ilAuthCredentials $credentials, $a_authmode)
Get provider by auth mode.