ILIAS  release_8 Revision v8.24
class.ilAuthFrontendFactory.php
Go to the documentation of this file.
1<?php
2
19declare(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
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()) {
78 $this->logger->debug('Init auth frontend with standard auth context');
79 $frontend = new ilAuthFrontendCLI(
81 $status,
82 $credentials,
83 $providers
84 );
85 return $frontend;
86
88 $this->logger->debug('Init auth frontend with webservice auth context');
89 $frontend = new ilAuthFrontendWS(
91 $status,
92 $credentials,
93 $providers
94 );
95 return $frontend;
96
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
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
118 $this->logger->error('Trying to init auth with empty context');
119 break;
120 }
121 return null;
122 }
123}
Factory for auth frontend classes.
getFrontend(ilAuthSession $session, ilAuthStatus $status, ilAuthCredentials $credentials, array $providers)
setContext(int $a_context)
Set context for following authentication requests.
Auth class for form based authentication.
Auth status implementation.
Component logger with individual log levels by component id.
global $DIC
Definition: feed.php:28
Interface of auth credentials.
Interface for auth methods (web form, http, ...)
$session