3 class Sabre_DAV_Auth_Backend_Friendica extends Sabre_DAV_Auth_Backend_AbstractBasic {
5 public function __construct() {
9 public function getUsers() {
10 return array($this->currentUser);
13 public function getCurrentUser() {
14 return $this->currentUser;
18 * Authenticates the user based on the current request.
20 * If authentication is successful, true must be returned.
21 * If authentication fails, an exception must be thrown.
23 * @param Sabre_DAV_Server $server
24 * @param string $realm
25 * @throws Sabre_DAV_Exception_NotAuthenticated
28 public function authenticate(Sabre_DAV_Server $server, $realm) {
30 $auth = new Sabre_HTTP_BasicAuth();
31 $auth->setHTTPRequest($server->httpRequest);
32 $auth->setHTTPResponse($server->httpResponse);
33 $auth->setRealm($realm);
34 $userpass = $auth->getUserPass();
36 $auth->requireLogin();
37 throw new Sabre_DAV_Exception_NotAuthenticated('No basic authentication headers were found');
40 // Authenticates the user
41 if (!$this->validateUserPass($userpass[0],$userpass[1])) {
42 $auth->requireLogin();
43 throw new Sabre_DAV_Exception_NotAuthenticated('Username or password does not match');
45 $this->currentUser = strtolower($userpass[0]);
50 protected function validateUserPass($username, $password) {
53 'uri' => "/" . 'principals/users/' . strtolower($username),