mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-09 18:08:49 +00:00
Initial Release of the calendar plugin
This commit is contained in:
parent
45cc9885fc
commit
7115197a33
561 changed files with 189494 additions and 0 deletions
58
dav/dav_friendica_auth.inc.php
Normal file
58
dav/dav_friendica_auth.inc.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
class Sabre_DAV_Auth_Backend_Friendica extends Sabre_DAV_Auth_Backend_AbstractBasic {
|
||||
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
|
||||
public function getUsers() {
|
||||
return array($this->currentUser);
|
||||
}
|
||||
|
||||
public function getCurrentUser() {
|
||||
return $this->currentUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticates the user based on the current request.
|
||||
*
|
||||
* If authentication is successful, true must be returned.
|
||||
* If authentication fails, an exception must be thrown.
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param string $realm
|
||||
* @throws Sabre_DAV_Exception_NotAuthenticated
|
||||
* @return bool
|
||||
*/
|
||||
public function authenticate(Sabre_DAV_Server $server, $realm) {
|
||||
|
||||
$auth = new Sabre_HTTP_BasicAuth();
|
||||
$auth->setHTTPRequest($server->httpRequest);
|
||||
$auth->setHTTPResponse($server->httpResponse);
|
||||
$auth->setRealm($realm);
|
||||
$userpass = $auth->getUserPass();
|
||||
if (!$userpass) {
|
||||
$auth->requireLogin();
|
||||
throw new Sabre_DAV_Exception_NotAuthenticated('No basic authentication headers were found');
|
||||
}
|
||||
|
||||
// Authenticates the user
|
||||
if (!$this->validateUserPass($userpass[0],$userpass[1])) {
|
||||
$auth->requireLogin();
|
||||
throw new Sabre_DAV_Exception_NotAuthenticated('Username or password does not match');
|
||||
}
|
||||
$this->currentUser = strtolower($userpass[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected function validateUserPass($username, $password) {
|
||||
|
||||
$user = array(
|
||||
'uri' => "/" . 'principals/users/' . strtolower($username),
|
||||
);
|
||||
return $user;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue