function setup() { if (!SABRE_HASSQLITE) { $this->markTestSkipped('No PDO SQLite support'); } $this->caldavBackend = Sabre_CalDAV_TestUtil::getBackend(); $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-read', array('principals/user1')); $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-write', array('principals/user1')); $principalBackend->addPrincipal(array('uri' => 'principals/admin/calendar-proxy-read')); $principalBackend->addPrincipal(array('uri' => 'principals/admin/calendar-proxy-write')); $calendars = new Sabre_CalDAV_CalendarRootNode($principalBackend, $this->caldavBackend); $principals = new Sabre_CalDAV_Principal_Collection($principalBackend); $root = new Sabre_DAV_SimpleCollection('root'); $root->addChild($calendars); $root->addChild($principals); $objectTree = new Sabre_DAV_ObjectTree($root); $this->server = new Sabre_DAV_Server($objectTree); $this->server->debugExceptions = true; $this->server->setBaseUri('/'); $this->plugin = new Sabre_CalDAV_Plugin(); $this->server->addPlugin($this->plugin); $this->response = new Sabre_HTTP_ResponseMock(); $this->server->httpResponse = $this->response; }
function setup() { $this->caldavBackend = new Sabre_CalDAV_Backend_Mock(array(array('id' => 1, 'uri' => 'UUID-123467', 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'user1 calendar', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description', '{http://apple.com/ns/ical/}calendar-order' => '1', '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT', 'VTODO'))), array('id' => 2, 'uri' => 'UUID-123468', 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'user1 calendar2', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description', '{http://apple.com/ns/ical/}calendar-order' => '1', '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT', 'VTODO')))), array(1 => array('UUID-2345' => array('calendardata' => Sabre_CalDAV_TestUtil::getTestCalendarData())))); $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-read', array('principals/user1')); $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-write', array('principals/user1')); $principalBackend->addPrincipal(array('uri' => 'principals/admin/calendar-proxy-read')); $principalBackend->addPrincipal(array('uri' => 'principals/admin/calendar-proxy-write')); $calendars = new Sabre_CalDAV_CalendarRootNode($principalBackend, $this->caldavBackend); $principals = new Sabre_CalDAV_Principal_Collection($principalBackend); $root = new Sabre_DAV_SimpleCollection('root'); $root->addChild($calendars); $root->addChild($principals); $objectTree = new Sabre_DAV_ObjectTree($root); $this->server = new Sabre_DAV_Server($objectTree); $this->server->debugExceptions = true; $this->server->setBaseUri('/'); $this->plugin = new Sabre_CalDAV_Plugin(); $this->server->addPlugin($this->plugin); // Adding ACL plugin $this->server->addPlugin(new Sabre_DAVACL_Plugin()); // Adding Auth plugin, and ensuring that we are logged in. $authBackend = new Sabre_DAV_Auth_MockBackend(); $authBackend->defaultUser = '******'; $authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'SabreDAV'); $this->server->addPlugin($authPlugin); $authPlugin->beforeMethod('GET', '/'); $this->response = new Sabre_HTTP_ResponseMock(); $this->server->httpResponse = $this->response; }
public function handle() { try { Tinebase_Core::initFramework(); } catch (Zend_Session_Exception $exception) { if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) { Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' invalid session. Delete session cookie.'); } Zend_Session::expireSessionCookie(); header('WWW-Authenticate: Basic realm="WebDAV for Tine 2.0"'); header('HTTP/1.1 401 Unauthorized'); return; } if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' is CalDav, CardDAV or WebDAV request.'); } if (empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['REMOTE_USER']) && empty($_SERVER['REDIRECT_REMOTE_USER'])) { header('WWW-Authenticate: Basic realm="WebDav for Tine 2.0"'); header('HTTP/1.1 401 Unauthorized'); return; } // when used with (f)cgi no PHP_AUTH variables are available without defining a special rewrite rule if (!isset($_SERVER['PHP_AUTH_USER'])) { // $_SERVER["REMOTE_USER"] == "Basic didhfiefdhfu4fjfjdsa34drsdfterrde..." $basicAuthData = base64_decode(substr(isset($_SERVER["REMOTE_USER"]) ? $_SERVER["REMOTE_USER"] : $_SERVER['REDIRECT_REMOTE_USER'], 6)); list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(":", $basicAuthData); } if (Tinebase_Controller::getInstance()->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'], $_SERVER['REMOTE_ADDR'], 'TineWebDav') !== true) { header('WWW-Authenticate: Basic realm="CardDav for Tine 2.0"'); header('HTTP/1.1 401 Unauthorized'); return; } self::$_server = new Sabre_DAV_Server(new Tinebase_WebDav_Root()); // compute base uri $request = new Zend_Controller_Request_Http(); self::$_server->setBaseUri($request->getBaseUrl() . '/'); $tempDir = Tinebase_Core::getTempDir(); if (!empty($tempDir)) { $lockBackend = new Sabre_DAV_Locks_Backend_File($tempDir . '/webdav.lock'); $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend); self::$_server->addPlugin($lockPlugin); } $authPlugin = new Sabre_DAV_Auth_Plugin(new Tinebase_WebDav_Auth(), null); self::$_server->addPlugin($authPlugin); $aclPlugin = new Sabre_DAVACL_Plugin(); $aclPlugin->defaultUsernamePath = 'principals/users'; $aclPlugin->principalCollectionSet = array($aclPlugin->defaultUsernamePath); self::$_server->addPlugin($aclPlugin); self::$_server->addPlugin(new Sabre_CardDAV_Plugin()); self::$_server->addPlugin(new Sabre_CalDAV_Plugin()); self::$_server->addPlugin(new Sabre_CalDAV_Schedule_Plugin()); self::$_server->addPlugin(new Sabre_DAV_Browser_Plugin()); self::$_server->exec(); }
/** * Fire up the SabreDAV server with our custom backends. * * This is mostly copied from the sabredav wiki */ public function indexAction() { // Backends $authBackend = new WebDAV_Helper_Auth(); $principalBackend = new Phprojekt_CalDAV_PrincipalBackend(); $calendarBackend = new Calendar2_CalDAV_CalendarBackend(); // Directory tree $tree = array(new Sabre_DAVACL_PrincipalCollection($principalBackend), new Sabre_CalDAV_CalendarRootNode($principalBackend, $calendarBackend)); $server = new Sabre_DAV_Server($tree); $server->setBaseUri('/index.php/Calendar2/caldav/index'); // Authentication plugin $authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'CalDAV'); $server->addPlugin($authPlugin); // CalDAV plugin $caldavPlugin = new Sabre_CalDAV_Plugin(); $server->addPlugin($caldavPlugin); // ACL plugin $aclPlugin = new Sabre_DAVACL_Plugin(); $server->addPlugin($aclPlugin); // Support for html frontend $browser = new Sabre_DAV_Browser_Plugin(); $server->addPlugin($browser); // And off we go! $server->exec(); }
public function process() { // initialize authentication $auth = new Sabre_HTTP_DigestAuth(); $auth->setRealm($this->app->config->site->auth_realm); $auth->init(); // authenticate and get correct user $email = $auth->getUsername(); $class_name = SwatDBClassMap::get('PinholeAdminUser'); $user = new $class_name(); $user->setDatabase($this->app->db); if (!$user->loadFromEmail($email) || !$auth->validateA1($user->digest_ha1)) { $auth->requireLogin(); echo Pinhole::_('Authentication required') . "\n"; exit; } // create directory for account and object tree for dav server $root = new PinholeDavDirectory($this->app, $user); $tree = new Sabre_DAV_ObjectTree($root); // create server $server = new Sabre_DAV_Server($tree); $server->setBaseUri($this->getDavBaseUri()); // don't save temp files in the database $tempFilePlugin = new Sabre_DAV_TemporaryFileFilterPlugin($this->getDataDir('dav/temp')); $server->addPlugin($tempFilePlugin); // set up lock plugin $lockBackend = new Sabre_DAV_Locks_Backend_FS($this->getDataDir('dav/locks')); $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend); $server->addPlugin($lockPlugin); // also allow regular web browsing $browserPlugin = new Sabre_DAV_Browser_Plugin(false); $server->addPlugin($browserPlugin); // serve it up! $server->exec(); }
public function indexAction() { // Set the root directory $webdavPath = Phprojekt::getInstance()->getConfig()->webdavPath; if (Phprojekt_Auth::isLoggedIn()) { $project = new Project_Models_Project(); $project = $project->find(1); $rootDirectory = new WebDAV_Models_ProjectDirectory($project); } else { // Some clients seem to send some queries without http auth. We need the dummy to serve those. $rootDirectory = new WebDAV_Models_EmptyDir(); } // The server object is responsible for making sense out of the WebDAV protocol $server = new Sabre_DAV_Server($rootDirectory); $server->setBaseUri($this->view->baseUrl('index.php/WebDAV/index/index/')); // The lock manager is reponsible for making sure users don't overwrite each others changes. // Change 'data' to a different directory, if you're storing your data somewhere else. $lockBackend = new Sabre_DAV_Locks_Backend_File($webdavPath . 'data/locks'); $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend); $server->addPlugin($lockPlugin); // Authentication $authBackend = new WebDAV_Helper_Auth(); $authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'WebDAV'); $server->addPlugin($authPlugin); // All we need to do now, is to fire up the server $server->exec(); }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $root = array(new \SteamDavDirectory($GLOBALS["STEAM"]->get_current_steam_user()->get_workroom()), new \Sabre_DAV_SimpleDirectory("Lesezeichen"), new \Sabre_DAV_SimpleDirectory("Gruppen"), new \Sabre_DAV_SimpleDirectory("Kurse")); $server = new \Sabre_DAV_Server($root); $server->setBaseUri("/webdav/index/"); // Support for html frontend $browser = new \Sabre_DAV_Browser_Plugin(); $server->addPlugin($browser); // And off we go! $server->exec(); exit; }
function testSerializeNoPrefix() { $href = new Sabre_DAV_Property_HrefList(array('foo', 'bar'), false); $this->assertEquals(array('foo', 'bar'), $href->getHrefs()); $doc = new DOMDocument(); $root = $doc->createElement('d:anything'); $root->setAttribute('xmlns:d', 'DAV:'); $doc->appendChild($root); $server = new Sabre_DAV_Server(); $server->setBaseUri('/bla/'); $href->serialize($server, $root); $xml = $doc->saveXML(); $this->assertEquals('<?xml version="1.0"?> <d:anything xmlns:d="DAV:"><d:href>foo</d:href><d:href>bar</d:href></d:anything> ', $xml); }
public function gallery() { $root = new Gallery3_DAV_Album(""); $tree = new Gallery3_DAV_Tree($root); // Skip the lock plugin for now, we don't want Finder to get write support for the time being. // $lock_backend = new Sabre_DAV_Locks_Backend_FS(TMPPATH . "sabredav"); // $lock = new Sabre_DAV_Locks_Plugin($lock_backend); $filter = new Sabre_DAV_TemporaryFileFilterPlugin(TMPPATH . "sabredav"); $server = new Sabre_DAV_Server($tree); $server->setBaseUri(url::site("webdav/gallery")); // $server->addPlugin($lock); $server->addPlugin($filter); if ($this->_authenticate()) { $server->exec(); } }
function testSerializeNoPrefix() { $href = new Sabre_DAV_Property_Href('path', false); $this->assertEquals('path', $href->getHref()); $doc = new DOMDocument(); $root = $doc->createElement('d:anything'); $root->setAttribute('xmlns:d', 'DAV:'); $doc->appendChild($root); $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('rootdir')); $server = new Sabre_DAV_Server($objectTree); $server->setBaseUri('/bla/'); $href->serialize($server, $root); $xml = $doc->saveXML(); $this->assertEquals('<?xml version="1.0"?> <d:anything xmlns:d="DAV:"><d:href>path</d:href></d:anything> ', $xml); }
/** * @depends testTreeMove * @depends testCopyMoveInfo */ function testEverything() { // Request object $serverVars = array('REQUEST_METHOD' => 'MOVE', 'REQUEST_URI' => '/webdav/foo', 'HTTP_DESTINATION' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', 'HTTP_OVERWRITE' => 'F'); $request = new Sabre_HTTP_Request($serverVars); $request->setBody(''); $response = new Sabre_HTTP_ResponseMock(); // Server setup mkdir(SABRE_TEMPDIR . '/issue33'); $dir = new Sabre_DAV_FS_Directory(SABRE_TEMPDIR . '/issue33'); $dir->createDirectory('foo'); $tree = new Sabre_DAV_ObjectTree($dir); $server = new Sabre_DAV_Server($tree); $server->setBaseUri('/webdav/'); $server->httpRequest = $request; $server->httpResponse = $response; $server->exec(); $this->assertTrue(file_exists(SABRE_TEMPDIR . '/issue33/' . urldecode('%C3%A0fo%C3%B3'))); }
/** * Handles a WebDAV request. */ public function requestAction() { if (!isset($this->_config->resources->sabredav->enabled) || 0 == $this->_config->resources->sabredav->enabled) { // Render 404 $response = $this->getResponse(); $response->clearAllHeaders(); $response->clearBody(); $response->setHttpResponseCode(404); $response->sendResponse(); return; } $baseUri = $this->view->url('@admin_webdav'); $publicDir = ROOT_PATH . '/public/uploads'; $tmpDir = ROOT_PATH . '/data/tmp'; $auth = new Sabre_HTTP_BasicAuth(); $auth->setRealm('Fizzy'); $authResult = $auth->getUserPass(); if (false === $authResult) { $auth->requireLogin(); die('Authentication required'); } list($username, $password) = $authResult; $authAdapter = new Fizzy_Doctrine_AuthAdapter($username, $password); $authResult = $authAdapter->authenticate(); if ($authResult->getCode() !== Zend_Auth_Result::SUCCESS) { $auth->requireLogin(); die('Authentication failed'); } $publicDirObj = new Sabre_DAV_FS_Directory($publicDir); $objectTree = new Sabre_DAV_ObjectTree($publicDirObj); $server = new Sabre_DAV_Server($objectTree); $server->setBaseUri($baseUri); if (isset($this->_config->resources->sabredav->browser) && false != $this->_config->resources->sabredav->browser) { $browser = new Sabre_DAV_Browser_Plugin(); $server->addPlugin($browser); } $server->exec(); }
function __construct(ipsRegistry $registry) { $this->registry = $registry; $this->DB = $this->registry->DB(); $this->settings =& $this->registry->fetchSettings(); $this->request =& $this->registry->fetchRequest(); $this->cache = $this->registry->cache(); $this->caches =& $this->registry->cache()->fetchCaches(); /* Set require path to include sabre directory */ @set_include_path(IPS_KERNEL_PATH . 'sabre/'); /*noLibHook*/ ipsRegistry::$settings['use_friendly_urls'] = 0; /* Fetch authentication library */ $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login'); $login = new $classToLoad($registry); /* Require spl for sabre */ require_once 'Sabre.autoload.php'; /*noLibHook*/ /* Attempt authentication */ $auth = new Sabre_HTTP_BasicAuth(); $auth->setRealm("IP.Board WebDav"); /* Enabled? */ if (!$this->settings['webdav_on']) { $auth->requireLogin(); echo "Please visit your Admin CP - Look and Feel - Externally Edit Templates and CSS to enable this functionality"; exit; } /* Fetch details */ $authDetails = $auth->getUserPass(); /* Check auth */ $member = IPSMember::load(IPSText::parseCleanValue($authDetails[0]), 'all', 'username'); if (!$member['member_id']) { $auth->requireLogin(); print "Authentication Required (User doesn't exist)"; exit; } /* Internal auth only */ $result = IPSMember::authenticateMember($member['member_id'], md5(IPSText::parseCleanValue($authDetails[1]))); if ($result === false) { $auth->requireLogin(); print "Authentication Required (Username or password incorrect)"; exit; } /* Load permissions class */ $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/classes/class_permissions.php', 'class_permissions'); $this->registry->setClass('class_permissions', new $classToLoad($this->registry)); if (!$member['g_access_cp']) { $auth->requireLogin(); print "Authentication Required (You are not an admin)"; exit; } if (!$this->registry->getClass('class_permissions')->checkPermission('settemplates_external_edit')) { $auth->requireLogin(); print "You are not permitted to edit skins externally"; exit; } /* Require some files for our sabre implementation */ require_once IPS_ROOT_PATH . 'sources/classes/sabre/root/skins.php'; /*noLibHook*/ require_once IPS_ROOT_PATH . 'sources/classes/sabre/directory/templates.php'; /*noLibHook*/ require_once IPS_ROOT_PATH . 'sources/classes/sabre/directory/groups.php'; /*noLibHook*/ require_once IPS_ROOT_PATH . 'sources/classes/sabre/files/templates.php'; /*noLibHook*/ require_once IPS_ROOT_PATH . 'sources/classes/sabre/lock/nolocks.php'; /*noLibHook*/ $tree = new Sabre_DAV_ObjectTree(new sabre_root_skins()); $server = new Sabre_DAV_Server($tree); $server->setBaseUri($this->getBaseUrl() . '/'); //$server->addPlugin( new Sabre_DAV_Browser_Plugin() ); $server->addPlugin(new Sabre_DAV_Locks_Plugin(new sabre_lock_nolocks())); /* Process */ $server->exec(); }
function index() { exit('webdav is not yet finished'); ob_clean(); $this->load->helper('url'); $publicDir = USERFILES . 'media/content'; $tmpDir = CACHEDIR . 'webdav'; $tmpDir = normalize_path($tmpDir); if (is_dir($tmpDir) == false) { mkdir($tmpDir); } $publicDir = normalize_path($publicDir); if (is_dir($publicDir) == false) { mkdir($publicDir); } // If you want to run the SabreDAV server in a custom location (using mod_rewrite for instance) // You can override the baseUri here. require_once BASEPATH . 'libraries/webshare/lib/Sabre.autoload.php'; $u = 'admin'; $p = '1234'; //$auth = new Sabre_HTTP_DigestAuth (); //$auth->init (); $is_valid = false; //$username_test = $auth->getUsername (); //$pass_test = $auth->validatePassword (); //$auth2 = new Sabre_HTTP_BasicAuth (); //$passresult = $auth2->getUserPass (); //p($passresult); /*if (! $username_test) { $is_valid = false; } else { $data = array (); $data ['username'] = $username_test; //$data ['password'] = $pass_test; $data ['is_active'] = 'y'; $data ['is_admin'] = 'y'; $data = CI::model ( 'users' )->getUsers ( $data ); $data = $data [0]; // if (! empty ( $data )) { //p($data); $pass_test = $auth->validatePassword ( $data ['password'] ); //p($pass_test); if ($pass_test == true) { $is_valid = true; } else { $is_valid = false; } } else { $is_valid = false; } //p($data); } if ($is_valid == false) { //$auth->requireLogin (); //echo "Authentication required\n"; //die (); }*/ // Create the root node $root = new Sabre_DAV_FS_Directory($publicDir); //..p($_SERVER); // The rootnode needs in turn to be passed to the server class $server = new Sabre_DAV_Server($root); //$baseUri = '/cms/webdav/'; $temp1 = site_url('webdav'); $temp1 = parse_url($temp1); //p($temp1); $baseUri = $temp1['path']; if (isset($baseUri)) { $server->setBaseUri($baseUri); } // Support for LOCK and UNLOCK $lockBackend = new Sabre_DAV_Locks_Backend_FS($tmpDir); $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend); $server->addPlugin($lockPlugin); $server->addPlugin(new Sabre_DAV_Mount_Plugin()); // Support for html frontend $browser = new Sabre_DAV_Browser_Plugin(); $server->addPlugin($browser); // Temporary file filter $tempFF = new Sabre_DAV_TemporaryFileFilterPlugin($tmpDir); $server->addPlugin($tempFF); // And off we go! $server->exec(); dav; }
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * License as published by the Free Software Foundation; either * version 3 of the License, or any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ // only need filesystem apps $RUNTIME_APPTYPES = array('filesystem', 'authentication'); OC_App::loadApps($RUNTIME_APPTYPES); // Backends $authBackend = new OC_Connector_Sabre_Auth(); $lockBackend = new OC_Connector_Sabre_Locks(); // Create ownCloud Dir $publicDir = new OC_Connector_Sabre_Directory(''); // Fire up server $server = new Sabre_DAV_Server($publicDir); $server->setBaseUri($baseuri); // Load plugins $server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend, 'ownCloud')); $server->addPlugin(new Sabre_DAV_Locks_Plugin($lockBackend)); $server->addPlugin(new Sabre_DAV_Browser_Plugin(false)); // Show something in the Browser, but no upload // And off we go! $server->exec();
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * License as published by the Free Software Foundation; either * version 3 of the License, or any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ // only need filesystem apps $RUNTIME_APPTYPES = array('filesystem', 'authentication'); require_once '../lib/base.php'; // Backends $authBackend = new OC_Connector_Sabre_Auth(); $lockBackend = new OC_Connector_Sabre_Locks(); // Create ownCloud Dir $publicDir = new OC_Connector_Sabre_Directory(''); // Fire up server $server = new Sabre_DAV_Server($publicDir); $server->setBaseUri(OC::$WEBROOT . '/files/webdav.php'); // Load plugins $server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend, 'ownCloud')); $server->addPlugin(new Sabre_DAV_Locks_Plugin($lockBackend)); $server->addPlugin(new Sabre_DAV_Browser_Plugin(false)); // Show something in the Browser, but no upload // And off we go! $server->exec();
<?php /** * Copyright (c) 2011 Jakob Sack <*****@*****.**> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ // Do not load FS ... $RUNTIME_NOSETUPFS = true; require_once '../../lib/base.php'; OC_Util::checkAppEnabled('calendar'); // Backends $authBackend = new OC_Connector_Sabre_Auth(); $principalBackend = new OC_Connector_Sabre_Principal(); $caldavBackend = new OC_Connector_Sabre_CalDAV(); // Root nodes $nodes = array(new Sabre_DAVACL_PrincipalCollection($principalBackend), new Sabre_CalDAV_CalendarRootNode($principalBackend, $caldavBackend)); // Fire up server $server = new Sabre_DAV_Server($nodes); $server->setBaseUri(OC::$WEBROOT . '/apps/calendar/caldav.php'); // Add plugins $server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend, 'ownCloud')); $server->addPlugin(new Sabre_CalDAV_Plugin()); $server->addPlugin(new Sabre_DAVACL_Plugin()); $server->addPlugin(new Sabre_DAV_Browser_Plugin(false)); // Show something in the Browser, but no upload // And off we go! $server->exec();
if (!$result || $result[0]!=$u || $result[1]!=$p) { $auth->requireLogin(); echo "Authentication required\n"; die(); } */ // Now we're creating a whole bunch of objects // Change public to something else, if you are using a different directory for your files // $rootDirectory = new Sabre_DAV_FS_Directory('files/standard'); $rootDirectory = new MyDirectory('files/standard'); // The server object is responsible for making sense out of the WebDAV protocol // Now we create an ObjectTree, which dispatches all requests to your newly created file system $objectTree = new Sabre_DAV_ObjectTree($rootDirectory); // The object tree needs in turn to be passed to the server class $server = new Sabre_DAV_Server($rootDirectory); // If your server is not on your webroot, make sure the following line has the correct information // $server->setBaseUri('/~evert/mydavfolder'); // if its in some kind of home directory $server->setBaseUri('/test/dav.php/'); // if you can't use mod_rewrite, use server.php as a base uri // $server->setBaseUri('/'); // ideally, SabreDAV lives on a root directory with mod_rewrite sending every request to server.php // The lock manager is reponsible for making sure users don't overwrite each others changes. Change 'data' to a different // directory, if you're storing your data somewhere else. $lockBackend = new Sabre_DAV_Locks_Backend_File('files/davdata/'); $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend); // $server->addPlugin($lockPlugin); $plugin = new Sabre_DAV_Browser_Plugin(); $server->addPlugin($plugin); // All we need to do now, is to fire up the server $server->exec();
/** * Setup then return the WebDAV server * * @return Sabre_DAV_Server */ function getServer() { // Authentication $auth = new WebDAVAuthentication(); $user = $auth->authenticate(); // Include the SabreDAV library $SabreDAVPath = $this->getPluginInfo()->getPropertyValueForName('sabredav_path'); require_once $SabreDAVPath . '/lib/Sabre/autoload.php'; require_once 'exception/WebDAVExceptionServerError.class.php'; // Creating the Root directory from WebDAV file system $maxFileSize = $this->getPluginInfo()->getPropertyValueForName('max_file_size'); require_once 'FS/WebDAVRoot.class.php'; $rootDirectory = new WebDAVRoot($this, $user, $maxFileSize); // The tree manages all the file objects require_once 'WebDAVTree.class.php'; $tree = new WebDAVTree($rootDirectory); // Finally, we create the server object. The server object is responsible for making sense out of the WebDAV protocol $server = new Sabre_DAV_Server($tree); // Base URI is the path used to access to WebDAV server $server->setBaseUri($this->getPluginInfo()->getPropertyValueForName('webdav_base_uri')); // The lock manager is reponsible for making sure users don't overwrite each others changes. // The locks repository is where temporary data related to locks is stored. $lockBackend = new Sabre_DAV_Locks_Backend_FS($GLOBALS['codendi_cache_dir'] . '/plugins/webdav/locks'); $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend); $server->addPlugin($lockPlugin); // Creating the browser plugin require_once 'BrowserPlugin.class.php'; $plugin = new BrowserPlugin(); $server->addPlugin($plugin); // The server is now ready to run return $server; }
/** * @brief handle webdav request * * @param bool $body * * @note this init procedure is copied from /apps/files/appinfo/remote.php */ function handleWebdavRequest($body = false) { // Backends $authBackend = new OC_Connector_Sabre_Auth(); $lockBackend = new OC_Connector_Sabre_Locks(); $requestBackend = new OC_Connector_Sabre_Request(); // Create ownCloud Dir $publicDir = new OC_Connector_Sabre_Directory(''); // Fire up server $server = new Sabre_DAV_Server($publicDir); $server->httpRequest = $requestBackend; $server->setBaseUri('/remote.php/webdav/'); // Load plugins $server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend, 'ownCloud')); $server->addPlugin(new Sabre_DAV_Locks_Plugin($lockBackend)); $server->addPlugin(new Sabre_DAV_Browser_Plugin(false)); // Show something in the Browser, but no upload $server->addPlugin(new OC_Connector_Sabre_QuotaPlugin()); $server->addPlugin(new OC_Connector_Sabre_MaintenancePlugin()); // And off we go! if ($body) { $server->httpRequest->setBody($body); } // turn on output buffering ob_start(); // handle request $server->exec(); // file content is written in the output buffer $content = ob_get_contents(); // flush the output buffer and turn off output buffering ob_end_clean(); // return captured content return $content; }
} else { header('Access-Control-Allow-Origin: *'); } $path = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["SCRIPT_NAME"])); $pathParts = explode('/', $path); // for webdav: // 0/ 1 / 2 / 3... // /$ownCloudUser/remoteStorage/$category/ if (count($pathParts) >= 3 && $pathParts[0] == '') { list($dummy, $ownCloudUser, $dummy2, $category) = $pathParts; OC_Util::setupFS($ownCloudUser); // Create ownCloud Dir $publicDir = new OC_Connector_Sabre_Directory(''); $server = new Sabre_DAV_Server($publicDir); // Path to our script $server->setBaseUri(OC::$WEBROOT . "/apps/remoteStorage/WebDAV.php/{$ownCloudUser}"); // Auth backend $authBackend = new OC_Connector_Sabre_Auth_ro_oauth(OC_remoteStorage::getValidTokens($ownCloudUser, $category), $category); $authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'ownCloud'); //should use $validTokens here $server->addPlugin($authPlugin); // Also make sure there is a 'data' directory, writable by the server. This directory is used to store information about locks $lockBackend = new OC_Connector_Sabre_Locks(); $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend); $server->addPlugin($lockPlugin); // And off we go! $server->exec(); } else { //die('not the right address format '.var_export($pathParts, true)); die('not the right address format'); }
} else { header('Access-Control-Allow-Origin: *'); } $path = substr($_SERVER["REQUEST_URI"], strlen($baseuri)); $pathParts = explode('/', $path); // for webdav: // 0 / 1 / 2... // $ownCloudUser/remoteStorage/$category/ if (count($pathParts) >= 2) { list($ownCloudUser, $dummy2, $category) = $pathParts; OC_Util::setupFS($ownCloudUser); // Create ownCloud Dir $publicDir = new OC_Connector_Sabre_Directory(''); $server = new Sabre_DAV_Server($publicDir); // Path to our script $server->setBaseUri($baseuri . $ownCloudUser); // Auth backend $authBackend = new OC_Connector_Sabre_Auth_ro_oauth(OC_remoteStorage::getValidTokens($ownCloudUser, $category), $category); $authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'ownCloud'); //should use $validTokens here $server->addPlugin($authPlugin); // Also make sure there is a 'data' directory, writable by the server. This directory is used to store information about locks $lockBackend = new OC_Connector_Sabre_Locks(); $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend); $server->addPlugin($lockPlugin); // And off we go! $server->exec(); } else { //die('not the right address format '.var_export($pathParts, true)); die('not the right address format'); }
require_once '../include/sabredav/lib/Sabre/autoload.php'; //require_once('../../../sabredav161/SabreDAV/lib/Sabre/autoload.php'); require_once 'DMSdirectory.class.php'; require_once 'DMSfile.class.php'; require_once 'auth.class.php'; $authBackend = new MyAuth(); // Creating the plugin. We're assuming that the realm // name is called 'SabreDAV'. $authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'FHTW'); // Change public to something else, if you are using a different directory for your files $rootDirectory = new DMSDirectory('', $authPlugin); // The server object is responsible for making sense out of the WebDAV protocol $server = new Sabre_DAV_Server($rootDirectory); // Adding the plugin to the server $server->addPlugin($authPlugin); // If your server is not on your webroot, make sure the following line has the correct information // $server->setBaseUri('/~evert/mydavfolder'); // if its in some kind of home directory // $server->setBaseUri('/dav/index.php/'); // if you can't use mod_rewrite, use index.php as a base uri // $server->setBaseUri('/'); // ideally, SabreDAV lives on a root directory with mod_rewrite sending every request to index.php $path = str_replace($_SERVER['DOCUMENT_ROOT'], '', __FILE__) . '/'; $server->setBaseUri($path); // The lock manager is reponsible for making sure users don't overwrite each others changes. Change 'data' to a different // directory, if you're storing your data somewhere else. $lockBackend = new Sabre_DAV_Locks_Backend_File('data/locks'); $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend); $server->addPlugin($lockPlugin); //GUI fuer Browser $browser = new Sabre_DAV_Browser_Plugin(); $server->addPlugin($browser); // All we need to do now, is to fire up the server $server->exec();
} } // Zarafa bridge $log->trace("Init bridge"); $bridge = new Zarafa_Bridge(); // Backends $log->trace("Loading backends"); $authBackend = new Zarafa_Auth_Basic_Backend($bridge); $principalBackend = new Zarafa_Principals_Backend($bridge); $carddavBackend = new Zarafa_CardDav_Backend($bridge); // Setting up the directory tree // $nodes = array(new Sabre_DAVACL_PrincipalCollection($principalBackend), new Sabre_CardDAV_AddressBookRoot($principalBackend, $carddavBackend)); // The object tree needs in turn to be passed to the server class $log->trace("Starting server"); $server = new Sabre_DAV_Server($nodes); $server->setBaseUri(CARDDAV_ROOT_URI); // Required plugins $log->trace("Adding plugins"); $server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend, SABRE_AUTH_REALM)); $server->addPlugin(new Sabre_CardDAV_Plugin()); $server->addPlugin(new Sabre_DAVACL_Plugin()); // Optional plugins if (SABRE_DAV_BROWSER_PLUGIN) { // Do not allow POST $server->addPlugin(new Sabre_DAV_Browser_Plugin(false)); } // Start server $log->trace("Server exec"); $log->info("SabreDAV version " . Sabre_DAV_Version::VERSION . '-' . Sabre_DAV_Version::STABILITY); $log->info("Producer: " . VCARD_PRODUCT_ID); $log->info("Revision: " . (SABRE_ZARAFA_REV + 1) . ' - ' . SABRE_ZARAFA_DATE);
* * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ // Do not load FS ... $RUNTIME_NOSETUPFS = true; require_once '../../lib/base.php'; OC_Util::checkAppEnabled('contacts'); // Backends $authBackend = new OC_Connector_Sabre_Auth(); $principalBackend = new OC_Connector_Sabre_Principal(); $carddavBackend = new OC_Connector_Sabre_CardDAV(); // Root nodes $nodes = array(new Sabre_DAVACL_PrincipalCollection($principalBackend), new Sabre_CardDAV_AddressBookRoot($principalBackend, $carddavBackend)); // Fire up server $server = new Sabre_DAV_Server($nodes); $server->setBaseUri(OC::$WEBROOT . '/apps/contacts/carddav.php'); // Add plugins $server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend, 'ownCloud')); $server->addPlugin(new Sabre_CardDAV_Plugin()); $server->addPlugin(new Sabre_DAVACL_Plugin()); $server->addPlugin(new Sabre_DAV_Browser_Plugin(false)); // Show something in the Browser, but no upload // And off we go! $server->exec();
log_message('error', "Error fetching identities for user '{$userName}': " . $response['Message']); return null; } // Initialize WebDAV authentication $realm = 'Inventory'; $auth = new Sabre_HTTP_DigestAuth(); $auth->setRealm($realm); $auth->init(); $userID = null; $userName = $auth->getUsername(); // Lookup the WebDAV ("a1hash") identity for the given username $hash = get_a1_hash($userName, $userID); // Check if the lookup was successful and that the credentials match if (!$hash || !$auth->validateA1($hash)) { log_message('info', "WebDAV Authentication failed for user '{$userName}' requesting " . $_SERVER['REQUEST_URI']); $auth->requireLogin(); echo "Authentication required\n"; exit; } // Construct the WebDAV tree and server objects $rootDirectory = new RootDirectory($userID); $tree = new Sabre_DAV_ObjectTree($rootDirectory); $server = new Sabre_DAV_Server($tree); $server->setBaseUri($config['webdav_url_base_path']); // Setup the WebDAV locking plugin $lockBackend = new Sabre_DAV_Locks_Backend_FS('tmp'); $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend); $server->addPlugin($lockPlugin); log_message('debug', "WebDAV handling " . $_SERVER['REQUEST_METHOD'] . " request for " . $_SERVER['REQUEST_URI']); // Execute the WebDAV request $server->exec();
} require $fileDir . '/library/Sabre/Sabre.autoload.php'; $request = new Zend_Controller_Request_Http(); $baseUrl = $request->getBaseUrl(); $auth = new Sabre_HTTP_BasicAuth(); $auth->setRealm('XenForo Admin CP WebDAV'); $authData = $auth->getUserPass(); /* @var $userModel XenForo_Model_User */ $userModel = XenForo_Model::create('XenForo_Model_User'); $authValid = false; $userId = $userModel->validateAuthentication($authData[0], $authData[1]); if ($userId) { $visitor = XenForo_Visitor::setup($userId); if ($visitor['is_admin']) { $authValid = true; } } if (!$authValid) { $auth->requireLogin(); echo "Authentication required"; exit; } $root = new XenForo_SabreDav_RootDirectory(); $tree = new Sabre_DAV_ObjectTree($root); $server = new Sabre_DAV_Server($tree); $server->setBaseUri($baseUrl . '/'); // implement but ignore locking, in attempt to allow finder, etc to do writes $lockBackend = new XenForo_SabreDav_LocksNoOp(); $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend); $server->addPlugin($lockPlugin); $server->exec();
/** * @param bool $force_authentication * @param bool $needs_caldav * @param bool $needs_carddav * @return Sabre_DAV_Server */ function dav_create_server($force_authentication = false, $needs_caldav = true, $needs_carddav = true) { $arr = array(new Sabre_DAV_SimpleCollection('principals', array(new Sabre_CalDAV_Principal_Collection(Sabre_DAVACL_PrincipalBackend_Std::getInstance(), "principals/users")))); if ($needs_caldav) { $arr[] = dav_createRootCalendarNode(); } if ($needs_carddav) { $arr[] = dav_createRootContactsNode(); } $tree = new Sabre_DAV_SimpleCollection('root', $arr); // The object tree needs in turn to be passed to the server class $server = new Sabre_DAV_Server($tree); if (CALDAV_URL_PREFIX != "") { $server->setBaseUri(CALDAV_URL_PREFIX); } $authPlugin = new Sabre_DAV_Auth_Plugin(Sabre_DAV_Auth_Backend_Std::getInstance(), DAV_APPNAME); $server->addPlugin($authPlugin); if ($needs_caldav) { $caldavPlugin = new Sabre_CalDAV_Plugin(); $server->addPlugin($caldavPlugin); } if ($needs_carddav) { $carddavPlugin = new Sabre_CardDAV_Plugin(); $server->addPlugin($carddavPlugin); } if ($GLOBALS["CALDAV_ACL_PLUGIN_CLASS"] != "") { $aclPlugin = new $GLOBALS["CALDAV_ACL_PLUGIN_CLASS"](); $aclPlugin->defaultUsernamePath = "principals/users"; $server->addPlugin($aclPlugin); } else { $aclPlugin = new Sabre_DAVACL_Plugin(); $aclPlugin->defaultUsernamePath = "principals/users"; $server->addPlugin($aclPlugin); } if ($force_authentication) { $server->broadcastEvent('beforeMethod', array("GET", "/")); } // Make it authenticate return $server; }
/** * @param App $a */ function dav_init(&$a) { /* * Recommended settings: * ALTER TABLE `photo` ADD INDEX ( `contact-id` ) */ dav_include_files(); if (false) { dbg(true); error_reporting(E_ALL); ini_set("display_errors", 1); } wdcal_create_std_calendars(); if ($a->argc >= 2 && $a->argv[1] == "wdcal") { if ($a->argc >= 3 && $a->argv[2] == "feed") { wdcal_print_feed($a->get_baseurl() . "/dav/wdcal/"); killme(); } elseif ($a->argc >= 3 && strlen($a->argv[2]) > 0) { wdcal_addRequiredHeadersEdit(); } else { wdcal_addRequiredHeaders(); } return; } if ($a->argc >= 2 && $a->argv[1] == "settings") { return; } $authBackend = new Sabre_DAV_Auth_Backend_Friendica(); $principalBackend = new Sabre_DAVACL_PrincipalBackend_Friendica($authBackend); $caldavBackend_std = new Sabre_CalDAV_Backend_Std(); $caldavBackend_community = new Sabre_CalDAV_Backend_Friendica(); $carddavBackend_std = new Sabre_CardDAV_Backend_Std(); $carddavBackend_community = new Sabre_CardDAV_Backend_FriendicaCommunity(); if (isset($_SERVER["PHP_AUTH_USER"])) { $tree = new Sabre_DAV_SimpleCollection('root', array(new Sabre_DAV_SimpleCollection('principals', array(new Sabre_CalDAV_Principal_Collection($principalBackend, "principals/users"))), new Sabre_CalDAV_AnimexxCalendarRootNode($principalBackend, array($caldavBackend_std, $caldavBackend_community)), new Sabre_CardDAV_AddressBookRootFriendica($principalBackend, array($carddavBackend_std, $carddavBackend_community)))); } else { $tree = new Sabre_DAV_SimpleCollection('root', array()); } // The object tree needs in turn to be passed to the server class $server = new Sabre_DAV_Server($tree); $url = parse_url($a->get_baseurl()); $server->setBaseUri(CALDAV_URL_PREFIX); $authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'SabreDAV'); $server->addPlugin($authPlugin); $aclPlugin = new Sabre_DAVACL_Plugin_Friendica(); $aclPlugin->defaultUsernamePath = "principals/users"; $server->addPlugin($aclPlugin); $caldavPlugin = new Sabre_CalDAV_Plugin(); $server->addPlugin($caldavPlugin); $carddavPlugin = new Sabre_CardDAV_Plugin(); $server->addPlugin($carddavPlugin); $browser = new Sabre_DAV_Browser_Plugin(); $server->addPlugin($browser); $server->exec(); killme(); }
<?php // Files we need require_once 'vendor/autoload.php'; // Now we're creating a whole bunch of objects // Change public to something else, if you are using a different directory for your files $rootDirectory = new Sabre_DAV_FS_Directory('public'); // The server object is responsible for making sense out of the WebDAV protocol $server = new Sabre_DAV_Server($rootDirectory); // If your server is not on your webroot, make sure the following line has the correct information $server->setBaseUri('/SabreDAV/server.php'); // if its in some kind of home directory // $server->setBaseUri('/dav/server.php/'); // if you can't use mod_rewrite, use server.php as a base uri // $server->setBaseUri('/'); // ideally, SabreDAV lives on a root directory with mod_rewrite sending every request to server.php // The lock manager is reponsible for making sure users don't overwrite each others changes. Change 'data' to a different // directory, if you're storing your data somewhere else. $lockBackend = new Sabre_DAV_Locks_Backend_File('data/locks'); $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend); $server->addPlugin($lockPlugin); // We assume $server is a Sabre_DAV_Server $plugin = new Sabre_DAV_Browser_Plugin(); $server->addPlugin($plugin); // All we need to do now, is to fire up the server $server->exec();