ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilAuthProviderFactory.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  private ilLogger $logger;
24 
25  public function __construct()
26  {
27  global $DIC;
28  $this->logger = $DIC->logger()->auth();
29  }
30 
34  public function getProviders(ilAuthCredentials $credentials): array
35  {
36  // Fixed provider selection;
37  if ($credentials->getAuthMode() !== '') {
38  $this->logger->debug('Returning fixed provider for auth mode: ' . $credentials->getAuthMode());
39  return [
40  $this->getProviderByAuthMode($credentials, $credentials->getAuthMode())
41  ];
42  }
43 
44  $auth_determination = ilAuthModeDetermination::_getInstance();
45  $sequence = $auth_determination->getAuthModeSequence($credentials->getUsername());
46 
47  $providers = [];
48  foreach ($sequence as $authmode) {
49  $provider = $this->getProviderByAuthMode($credentials, (string) $authmode);
50  if ($provider instanceof ilAuthProviderInterface) {
51  $providers[] = $provider;
52  }
53  }
54 
55  return $providers;
56  }
57 
61  public function getProviderByAuthMode(ilAuthCredentials $credentials, $a_authmode): ?ilAuthProviderInterface
62  {
63  switch ((int) $a_authmode) {
65  $ldap_info = explode('_', $a_authmode);
66  $this->logger->debug('Using ldap authentication with credentials ');
67  return new ilAuthProviderLDAP($credentials, (int) $ldap_info[1]);
68 
70  $this->logger->debug('Using local database authentication');
71  return new ilAuthProviderDatabase($credentials);
72 
74  $this->logger->debug('Using SOAP authentication.');
75  return new ilAuthProviderSoap($credentials);
76 
78  $this->logger->debug('Using apache authentication.');
79  return new ilAuthProviderApache($credentials);
80 
82  $this->logger->debug('Using shibboleth authentication.');
83  return new ilAuthProviderShibboleth($credentials);
84 
86  $this->logger->debug('Using lti provider authentication.');
87  return new ilAuthProviderLTI($credentials);
88 
90  $this->logger->debug('Using ecs authentication.');
91  return new ilAuthProviderECS($credentials);
92 
94  $this->logger->debug('Using apache authentication.');
95  return new ilAuthProviderSaml($credentials, ilSamlIdp::getIdpIdByAuthMode($a_authmode));
96 
98  $this->logger->debug('Using openid connect authentication.');
99  return new ilAuthProviderOpenIdConnect($credentials);
100 
101  default:
102  $this->logger->debug('Plugin authentication: ' . $a_authmode);
103  foreach (ilAuthUtils::getAuthPlugins() as $pl) {
104  $provider = $pl->getProvider($credentials, $a_authmode);
105  if ($provider instanceof ilAuthProviderInterface) {
106  return $provider;
107  }
108  }
109  break;
110  }
111 
112  return null;
113  }
114 }
const int AUTH_SOAP
getProviders(ilAuthCredentials $credentials)
const int AUTH_SHIBBOLETH
const int AUTH_APACHE
static getIdpIdByAuthMode(string $a_auth_mode)
const int AUTH_ECS
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getAuthPlugins()
$provider
Definition: ltitoken.php:80
Auth prvider for ecs auth.
const int AUTH_LOCAL
global $DIC
Definition: shib_login.php:26
const int AUTH_PROVIDER_LTI
OAuth based lti authentication.
const int AUTH_LDAP
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const int AUTH_SAML
const int AUTH_OPENID_CONNECT
getProviderByAuthMode(ilAuthCredentials $credentials, $a_authmode)