ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilWebDAVAuthentication Class Reference

Class ilWebDAVAuthentication. More...

+ Collaboration diagram for ilWebDAVAuthentication:

Public Member Functions

 isUserAgentSessionAware ($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  include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendCredentialsHTTP.php';
80  $credentials = new ilAuthFrontendCredentialsHTTP();
81  $credentials->setUsername($a_username);
82  $credentials->setPassword($a_password);
83 
84  include_once './Services/Authentication/classes/Provider/class.ilAuthProviderFactory.php';
85  $provider_factory = new ilAuthProviderFactory();
86  $providers = $provider_factory->getProviders($credentials);
87 
88  include_once './Services/Authentication/classes/class.ilAuthStatus.php';
89  $status = ilAuthStatus::getInstance();
90 
91  include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendFactory.php';
92  $frontend_factory = new ilAuthFrontendFactory();
93  $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_HTTP);
94  $frontend = $frontend_factory->getFrontend(
95  $DIC['ilAuthSession'],
96  $status,
97  $credentials,
98  $providers
99  );
100 
101  $frontend->authenticate();
102 
103  switch ($status->getStatus()) {
105  ilLoggerFactory::getLogger('webdav')->debug('User authenticated through basic authentication. UserId = ' . $DIC->user()->getId());
106  return true;
107 
109  ilLoggerFactory::getLogger('webdav')->info('Basic authentication failed; Account migration required.');
110  return false;
111 
113  ilLoggerFactory::getLogger('webdav')->info('Basic authentication failed; Wrong login, password.');
114  return false;
115  }
116 
117  return false;
118  }
static enableWebAccessWithoutSession($enable_web_access_without_session)
getUserAgent()
Gets the given user agent from the request.
global $DIC
Definition: saml.php:7
const STATUS_AUTHENTICATION_FAILED
Factory for auth frontend classes.
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().

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  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
+ Here is the caller graph for this function:

◆ isUserAgentSessionAware()

ilWebDAVAuthentication::isUserAgentSessionAware (   $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().

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: