ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
ILIAS\WebDAV\Auth\ILIASAuthenticationCallback Class Reference
+ Collaboration diagram for ILIAS\WebDAV\Auth\ILIASAuthenticationCallback:

Public Member Functions

 __construct (protected ilObjUser $user, protected ilAuthSession $session, protected ilLogger $logger, Filesystem $filesystem, SecretKeyRotation $secret_key_rotation)
 
 authenticate (string $a_username, string $a_password)
 

Protected Member Functions

 isUserAgentSessionAware (string $user_agent)
 
 getUserAgent ()
 

Protected Attributes

array $session_aware_webdav_clients
 

Private Attributes

ILIASAuthenticationFileCache $file_cache
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ILIAS\WebDAV\Auth\ILIASAuthenticationCallback::__construct ( protected ilObjUser  $user,
protected ilAuthSession  $session,
protected ilLogger  $logger,
Filesystem  $filesystem,
SecretKeyRotation  $secret_key_rotation 
)

Definition at line 57 of file ILIASAuthenticationCallback.php.

63 {
64 $this->file_cache = new ILIASAuthenticationFileCache(
65 $filesystem,
66 $secret_key_rotation
67 );
68 }

Member Function Documentation

◆ authenticate()

ILIAS\WebDAV\Auth\ILIASAuthenticationCallback::authenticate ( string  $a_username,
string  $a_password 
)

Definition at line 80 of file ILIASAuthenticationCallback.php.

80 : bool
81 {
82 global $DIC;
83
84 $cached = $this->file_cache->isAuthenticated($a_username, $a_password);
85 if ($cached !== null) {
86 $this->logger->info('WEBDAV: User authenticated through cache. UserID = ' . $cached);
87 $DIC->user()->setId($cached);
89 return true;
90 }
91 if ($this->isUserAgentSessionAware($this->getUserAgent())) {
92 if ($this->session->isAuthenticated()
93 && $this->user->getId() !== 0
94 && $this->user->getId() !== ANONYMOUS_USER_ID) {
95 $this->logger->debug('User authenticated through session. UserID = ' . $this->user->getId());
96 return true;
97 }
98 } else {
100 }
101
102 $credentials = new ilAuthFrontendCredentialsHTTP();
103 $credentials->setUsername($a_username);
104 $credentials->setPassword($a_password);
105
106 $provider_factory = new ilAuthProviderFactory();
107 $providers = $provider_factory->getProviders($credentials);
108
109 $status = ilAuthStatus::getInstance();
110
111 $frontend_factory = new ilAuthFrontendFactory();
112 $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_HTTP);
113 $frontend = $frontend_factory->getFrontend(
114 $this->session,
115 $status,
116 $credentials,
117 $providers
118 );
119
120 $frontend->authenticate();
121
122 switch ($status->getStatus()) {
124 $this->logger->debug(
125 'User authenticated through basic authentication. UserId = ' . $this->user->getId()
126 );
127
128 $this->file_cache->setAuthenticated($a_username, $a_password, (int) $DIC->user()->getId());
129 return true;
130
132 $this->logger->info('Basic authentication failed; Account migration required.');
133 return false;
134
136 $this->logger->info('Basic authentication failed; Wrong login, password.');
137 return false;
138 }
139
140 return false;
141 }
const int STATUS_AUTHENTICATION_FAILED
const int STATUS_ACCOUNT_MIGRATION_REQUIRED
const int STATUS_AUTHENTICATED
static getInstance()
Get status instance.
static enableWebAccessWithoutSession(bool $enable_web_access_without_session)
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: shib_login.php:26

References $DIC, ANONYMOUS_USER_ID, ilAuthFrontendFactory\CONTEXT_HTTP, ilSession\enableWebAccessWithoutSession(), ilAuthStatus\getInstance(), ILIAS\WebDAV\Auth\ILIASAuthenticationCallback\getUserAgent(), ILIAS\WebDAV\Auth\ILIASAuthenticationCallback\isUserAgentSessionAware(), ILIAS\Repository\logger(), ilAuthStatus\STATUS_ACCOUNT_MIGRATION_REQUIRED, ilAuthStatus\STATUS_AUTHENTICATED, ilAuthStatus\STATUS_AUTHENTICATION_FAILED, and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ getUserAgent()

ILIAS\WebDAV\Auth\ILIASAuthenticationCallback::getUserAgent ( )
protected

Definition at line 75 of file ILIASAuthenticationCallback.php.

75 : string
76 {
77 return $_SERVER["HTTP_USER_AGENT"] ?? '';
78 }
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26

References $_SERVER.

Referenced by ILIAS\WebDAV\Auth\ILIASAuthenticationCallback\authenticate().

+ Here is the caller graph for this function:

◆ isUserAgentSessionAware()

ILIAS\WebDAV\Auth\ILIASAuthenticationCallback::isUserAgentSessionAware ( string  $user_agent)
protected

Definition at line 70 of file ILIASAuthenticationCallback.php.

70 : bool
71 {
72 return array_any($this->session_aware_webdav_clients, fn($webdav_client_name): string|false => stristr($user_agent, (string) $webdav_client_name));
73 }

Referenced by ILIAS\WebDAV\Auth\ILIASAuthenticationCallback\authenticate().

+ Here is the caller graph for this function:

Field Documentation

◆ $file_cache

ILIASAuthenticationFileCache ILIAS\WebDAV\Auth\ILIASAuthenticationCallback::$file_cache
private

Definition at line 39 of file ILIASAuthenticationCallback.php.

◆ $session_aware_webdav_clients

array ILIAS\WebDAV\Auth\ILIASAuthenticationCallback::$session_aware_webdav_clients
protected
Initial value:
= [
"Microsoft-WebDAV-MiniRedir",
"gvfs"
]

Definition at line 52 of file ILIASAuthenticationCallback.php.


The documentation for this class was generated from the following file: