ILIAS  release_8 Revision v8.23
ilWebDAVAuthentication Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilWebDAVAuthentication:

Public Member Functions

 __construct (ilObjUser $user, ilAuthSession $session)
 
 authenticate (string $a_username, string $a_password)
 

Protected Member Functions

 isUserAgentSessionAware (string $user_agent)
 
 getUserAgent ()
 

Protected Attributes

array $session_aware_webdav_clients
 
ilObjUser $user
 
ilAuthSession $session
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Author
Raphael Heer rapha.nosp@m.el.h.nosp@m.eer@h.nosp@m.slu..nosp@m.ch

Definition at line 24 of file class.ilWebDAVAuthentication.php.

Constructor & Destructor Documentation

◆ __construct()

ilWebDAVAuthentication::__construct ( ilObjUser  $user,
ilAuthSession  $session 
)

Definition at line 46 of file class.ilWebDAVAuthentication.php.

References $session, $user, and ILIAS\Repository\user().

47  {
48  $this->user = $user;
49  $this->session = $session;
50  }
+ Here is the call graph for this function:

Member Function Documentation

◆ authenticate()

ilWebDAVAuthentication::authenticate ( string  $a_username,
string  $a_password 
)

Definition at line 70 of file class.ilWebDAVAuthentication.php.

References ilAuthFrontendFactory\CONTEXT_HTTP, ilSession\enableWebAccessWithoutSession(), ilAuthStatus\getInstance(), ilLoggerFactory\getLogger(), getUserAgent(), isUserAgentSessionAware(), ilAuthStatus\STATUS_ACCOUNT_MIGRATION_REQUIRED, ilAuthStatus\STATUS_AUTHENTICATED, ilAuthStatus\STATUS_AUTHENTICATION_FAILED, and ILIAS\Repository\user().

70  : bool
71  {
72  if ($this->isUserAgentSessionAware($this->getUserAgent())) {
73  if ($this->session->isAuthenticated() && $this->user->getId() != 0) {
74  ilLoggerFactory::getLogger('webdav')->debug('User authenticated through session. UserID = ' . $this->user->getId());
75  return true;
76  }
77  } else {
79  }
80 
81  $credentials = new ilAuthFrontendCredentialsHTTP();
82  $credentials->setUsername($a_username);
83  $credentials->setPassword($a_password);
84 
85  $provider_factory = new ilAuthProviderFactory();
86  $providers = $provider_factory->getProviders($credentials);
87 
88  $status = ilAuthStatus::getInstance();
89 
90  $frontend_factory = new ilAuthFrontendFactory();
91  $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_HTTP);
92  $frontend = $frontend_factory->getFrontend(
93  $this->session,
94  $status,
95  $credentials,
96  $providers
97  );
98 
99  $frontend->authenticate();
100 
101  switch ($status->getStatus()) {
103  ilLoggerFactory::getLogger('webdav')->debug('User authenticated through basic authentication. UserId = ' . $this->user->getId());
104  return true;
105 
107  ilLoggerFactory::getLogger('webdav')->info('Basic authentication failed; Account migration required.');
108  return false;
109 
111  ilLoggerFactory::getLogger('webdav')->info('Basic authentication failed; Wrong login, password.');
112  return false;
113  }
114 
115  return false;
116  }
static enableWebAccessWithoutSession(bool $enable_web_access_without_session)
isUserAgentSessionAware(string $user_agent)
static getLogger(string $a_component_id)
Get component logger.
const STATUS_AUTHENTICATION_FAILED
Factory for auth frontend classes.
static getInstance()
Get status instance.
const STATUS_ACCOUNT_MIGRATION_REQUIRED
+ Here is the call graph for this function:

◆ getUserAgent()

ilWebDAVAuthentication::getUserAgent ( )
protected

Definition at line 62 of file class.ilWebDAVAuthentication.php.

References $_SERVER.

Referenced by authenticate().

62  : string
63  {
64  $user_agent = $_SERVER["HTTP_USER_AGENT"] ?? "";
65  $user_agent = is_string($user_agent) ? $user_agent : "";
66 
67  return $user_agent;
68  }
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
+ Here is the caller graph for this function:

◆ isUserAgentSessionAware()

ilWebDAVAuthentication::isUserAgentSessionAware ( string  $user_agent)
protected

Definition at line 52 of file class.ilWebDAVAuthentication.php.

Referenced by authenticate().

52  : bool
53  {
54  foreach ($this->session_aware_webdav_clients as $webdav_client_name) {
55  if (stristr($user_agent, $webdav_client_name)) {
56  return true;
57  }
58  }
59  return false;
60  }
+ Here is the caller graph for this function:

Field Documentation

◆ $session

ilAuthSession ilWebDAVAuthentication::$session
protected

Definition at line 44 of file class.ilWebDAVAuthentication.php.

Referenced by __construct().

◆ $session_aware_webdav_clients

array ilWebDAVAuthentication::$session_aware_webdav_clients
protected
Initial value:
= [
"Microsoft-WebDAV-MiniRedir",
"gvfs"
]

Definition at line 38 of file class.ilWebDAVAuthentication.php.

◆ $user

ilObjUser ilWebDAVAuthentication::$user
protected

Definition at line 43 of file class.ilWebDAVAuthentication.php.

Referenced by __construct().


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