ILIAS  release_7 Revision v7.30-3-g800a261c036
ilWebDAVAuthentication Class Reference

Class ilWebDAVAuthentication. More...

+ Collaboration diagram for ilWebDAVAuthentication:

Public Member Functions

 isUserAgentSessionAware (string $user_agent)
 
 authenticate ($a_username, $a_password)
 Callback function. More...
 

Protected Member Functions

 getUserAgent ()
 Gets the given user agent from the request. More...
 

Protected Attributes

 $session_aware_webdav_clients
 

Detailed Description

Class ilWebDAVAuthentication.

Implements the callback to authenticate users. Is called by the sabreDAV Authentication Plugin

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

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

Member Function Documentation

◆ authenticate()

ilWebDAVAuthentication::authenticate (   $a_username,
  $a_password 
)

Callback function.

Identifies user by username and password and returns if authentication was successful

Parameters
$a_username
$a_password
Returns
bool

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

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

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

◆ getUserAgent()

ilWebDAVAuthentication::getUserAgent ( )
protected

Gets the given user agent from the request.

If user agent is not set -> return an empty string

Returns
string

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

References $_SERVER.

Referenced by authenticate().

48  : string
49  {
50  // is user agent set?
51  $user_agent = isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : "";
52 
53  // is value of user agent a string?
54  $user_agent = is_string($user_agent) ? $user_agent : "";
55 
56  return $user_agent;
57  }
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
+ Here is the caller graph for this function:

◆ isUserAgentSessionAware()

ilWebDAVAuthentication::isUserAgentSessionAware ( string  $user_agent)
Parameters
string$user_agentUser Agent from $_SERVER["HTTP_USER_AGENT"]
Returns
bool

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

Referenced by authenticate().

34  : bool
35  {
36  foreach ($this->session_aware_webdav_clients as $webdav_client_name) {
37  if (stristr($user_agent, $webdav_client_name)) {
38  return true;
39  }
40  }
41  return false;
42  }
+ Here is the caller graph for this function:

Field Documentation

◆ $session_aware_webdav_clients

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

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


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