ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
AbstractBasic.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use Sabre\DAV;
6 use Sabre\HTTP;
9 
22 abstract class AbstractBasic implements BackendInterface {
23 
32  protected $realm = 'sabre/dav';
33 
39  protected $principalPrefix = 'principals/';
40 
51  abstract protected function validateUserPass($username, $password);
52 
59  function setRealm($realm) {
60 
61  $this->realm = $realm;
62 
63  }
64 
94 
95  $auth = new HTTP\Auth\Basic(
96  $this->realm,
97  $request,
98  $response
99  );
100 
101  $userpass = $auth->getCredentials();
102  if (!$userpass) {
103  return [false, "No 'Authorization: Basic' header found. Either the client didn't send one, or the server is misconfigured"];
104  }
105  if (!$this->validateUserPass($userpass[0], $userpass[1])) {
106  return [false, "Username or password was incorrect"];
107  }
108  return [true, $this->principalPrefix . $userpass[0]];
109 
110  }
111 
134 
135  $auth = new HTTP\Auth\Basic(
136  $this->realm,
137  $request,
138  $response
139  );
140  $auth->requireLogin();
141 
142  }
143 
144 }
This interface represents a HTTP response.
The RequestInterface represents a HTTP request.
setRealm($realm)
Sets the authentication realm for this backend.
challenge(RequestInterface $request, ResponseInterface $response)
This method is called when a user could not be authenticated, and authentication was required for the...
foreach($paths as $path) $request
Definition: asyncclient.php:32
HTTP Basic authentication backend class.
$auth
Definition: fileserver.php:48
check(RequestInterface $request, ResponseInterface $response)
When this method is called, the backend must check if authentication was successful.
validateUserPass($username, $password)
Validates a username and password.
$password
Definition: cron.php:14
This is the base class for any authentication object.
$response
HTTP Basic authentication utility.
Definition: Basic.php:18