]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/lib/Sabre/DAV/Auth/Backend/Apache.php
Merge pull request #57 from CatoTH/master
[friendica-addons.git] / dav / SabreDAV / lib / Sabre / DAV / Auth / Backend / Apache.php
1 <?php
2
3 /**
4  * Apache authenticator
5  *
6  * This authentication backend assumes that authentication has been
7  * configured in apache, rather than within SabreDAV.
8  *
9  * Make sure apache is properly configured for this to work.
10  *
11  * @package Sabre
12  * @subpackage DAV
13  * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
14  * @author Evert Pot (http://www.rooftopsolutions.nl/) 
15  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
16  */
17 class Sabre_DAV_Auth_Backend_Apache implements Sabre_DAV_Auth_IBackend {
18
19     /**
20      * Current apache user
21      *
22      * @var string
23      */
24     protected $remoteUser;
25
26     /**
27      * Authenticates the user based on the current request.
28      *
29      * If authentication is successful, true must be returned.
30      * If authentication fails, an exception must be thrown.
31      *
32      * @param Sabre_DAV_Server $server
33      * @param string $realm
34      * @return bool
35      */
36     public function authenticate(Sabre_DAV_Server $server, $realm) {
37
38         $remoteUser = $server->httpRequest->getRawServerValue('REMOTE_USER');
39         if (is_null($remoteUser)) {
40             throw new Sabre_DAV_Exception('We did not receive the $_SERVER[REMOTE_USER] property. This means that apache might have been misconfigured');
41         }
42
43         $this->remoteUser = $remoteUser;
44         return true;
45
46     }
47
48     /**
49      * Returns information about the currently logged in user.
50      *
51      * If nobody is currently logged in, this method should return null.
52      *
53      * @return array|null
54      */
55     public function getCurrentUser() {
56
57         return $this->remoteUser;
58
59     }
60
61 }
62