ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAuthFrontendFactory.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
28 {
29  private const CONTEXT_UNDEFINED = 0;
30 
31  // authentication with id and password. Used for standard form based authentication
32  // soap auth (login) but not for (CLI (cron)?) and HTTP basic authentication
33  public const CONTEXT_STANDARD_FORM = 2;
34 
35  // CLI context for cron
36  public const CONTEXT_CLI = 3;
37 
38  // Rest soap context
39  public const CONTEXT_WS = 4;
40 
41  // http auth
42  public const CONTEXT_HTTP = 5;
43 
44 
45  private int $context = self::CONTEXT_UNDEFINED;
46  private ilLogger $logger;
47 
48 
52  public function __construct()
53  {
54  global $DIC;
55  $this->logger = $DIC->logger()->auth();
56  }
57 
61  public function setContext(int $a_context): void
62  {
63  $this->context = $a_context;
64  }
65 
69  public function getContext(): int
70  {
71  return $this->context;
72  }
73 
74  public function getFrontend(ilAuthSession $session, ilAuthStatus $status, ilAuthCredentials $credentials, array $providers): ?ilAuthFrontendInterface
75  {
76  switch ($this->getContext()) {
77  case self::CONTEXT_CLI:
78  $this->logger->debug('Init auth frontend with standard auth context');
79  $frontend = new ilAuthFrontendCLI(
80  $session,
81  $status,
82  $credentials,
83  $providers
84  );
85  return $frontend;
86 
87  case self::CONTEXT_WS:
88  $this->logger->debug('Init auth frontend with webservice auth context');
89  $frontend = new ilAuthFrontendWS(
90  $session,
91  $status,
92  $credentials,
93  $providers
94  );
95  return $frontend;
96 
97  case self::CONTEXT_STANDARD_FORM:
98  $this->logger->debug('Init auth frontend with standard auth context');
99  $frontend = new ilAuthStandardFormFrontend(
100  $session,
101  $status,
102  $credentials,
103  $providers
104  );
105  return $frontend;
106 
107  case self::CONTEXT_HTTP:
108  $this->logger->debug('Init auth frontend with http basic auth context');
109  $frontend = new ilAuthFrontendHTTP(
110  $session,
111  $status,
112  $credentials,
113  $providers
114  );
115  return $frontend;
116 
117  case self::CONTEXT_UNDEFINED:
118  $this->logger->error('Trying to init auth with empty context');
119  break;
120  }
121  return null;
122  }
123 }
Interface of auth credentials.
Factory for auth frontend classes.
$session
global $DIC
Definition: feed.php:28
getFrontend(ilAuthSession $session, ilAuthStatus $status, ilAuthCredentials $credentials, array $providers)
Interface for auth methods (web form, http, ...)
Auth class for form based authentication.
Auth status implementation.
setContext(int $a_context)
Set context for following authentication requests.