0

My team is trying to get WebDAV setup to allow users to share access to specific files if the users belongs to the same project, but hide/block access otherwise.

Reading the docs we think we're setting it up properly, but keep getting this error when authenticating.

http://newui.proloop.com/dav/
rickatech
password (don't worry, nothing valuable here)

This XML file does not appear to have any style information
associated with it. The document tree is shown below.
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
<s:sabredav-version>3.2.0</s:sabredav-version>
<s:exception>Sabre\DAV\Exception\NotFound</s:exception>
<s:message>File not found: rickatech in 'principals'</s:message>
</d:error>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">...</d:error>

.../dav/index.php

<?php
namespace LawLoop;
date_default_timezone_set('UTC');

require '../vendor/autoload.php';

use Sabre\DAV;
use Sabre\DAV\FSExt;
use Sabre\DAV\FSExt\File;
use Sabre\DAV\Auth;
use Sabre\DAVACL\FS\HomeCollection;

function PSQLParams()
{
    $host = 'proloop.ckyj1meiloyg.us-east-1.rds.amazonaws.com';
    $port = 5432;
    $dbname = '[redacted]';

    $username = '[redacted]';
    $password = '[redacted]';

    $dsn = "pgsql:host={$host};port={$port};dbname={$dbname}";

    return array(
        'host' => $host,
        'port' => $port,
        'dbname' => $dbname,
        'username' => $username,
        'password' => $password,
        'dsn' => $dsn
        );
}

$dbparams = PSQLParams();

$db = new \PDO($dbparams['dsn'], $dbparams['username'], $dbparams['password']);
$db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

$aclPlugin = new \Sabre\DAVACL\Plugin();
$aclPlugin->hideNodesFromListings = true;
$aclPlugin->defaultUsernamePath = 'principals/users';
$aclPlugin->adminPrincipals[] = 'principals/admin';

$authBackend = new \Sabre\DAV\Auth\Backend\PDO($db);
$principalBackend = new \Sabre\DAVACL\PrincipalBackend\PDO($db);

$principalsCollection = new \Sabre\DAV\SimpleCollection('principals', [
        new \Sabre\DAVACL\PrincipalCollection($principalBackend, 'principals/users')//,
//        new \Sabre\DAVACL\PrincipalCollection($principalBackend, 'principals/projects'),
//        new \Sabre\DAVACL\PrincipalCollection($principalBackend, 'principals/organizations')
    ]);

$home = new HomeCollection($principalBackend,'/efs/users');
$projects = new HomeCollection($principalBackend,'/efs/dav/projects');
$projects->collectionName = 'projects';
$organizations = new HomeCollection($principalBackend,'/efs/dav/organizations');

$organizations->collectionName = 'organizations';
$tree = [
    $home, $projects, $organizations, $principalsCollection
];

$server = new DAV\Server($tree);

//  ver->setBaseUri("/servref/server.php");
$server->setBaseUri("/dav/");

$lockBackend = new DAV\Locks\Backend\PDO($db);
$lockPlugin = new DAV\Locks\Plugin($lockBackend);

$authBackend = new Auth\Backend\PDO($db);

// We're assuming that the realm name is called 'ProLoop'.
$authBackend->setRealm('dav');

// Creating the plugin.
$authPlugin = new Auth\Plugin($authBackend);

// Adding the plugin to the server.
$server->addPlugin($authPlugin);
$server->addPlugin($aclPlugin);
$server->addPlugin($lockPlugin);
$server->addPlugin(new DAV\Browser\Plugin());

$server->exec();

I've also posted this on StackOverflow as I'm not sure if this is coding question vs service configuration. https://stackoverflow.com/questions/43060444/webdav-sabre-io-php-enabling-group-methods-throwing-errors

sabre.io has support forum, but I sense this is something StackExchange folk might have more insight into. https://groups.google.com/forum/#!topic/sabredav-discuss/MSSjwccjuP8

enter image description here enter image description here

rickatech
  • 141
  • 8

1 Answers1

1

So ended up just writing our own custom collection handler, which checks current logged in user against some tables that we manage group/project membership.

sabre.io doesn't really show how straight forward this is to do, so spent a lot of time trying to see if there was already a best practice, couldn't find one, so just wrote our own and it works just fine.

rickatech
  • 141
  • 8