WebDAV sabre.io PHP,启用组方法抛出错误

WebDAV sabre.io PHP,启用组方法抛出错误

我的团队正在尝试设置 WebDAV,以允许用户在属于同一个项目的情况下共享对特定文件的访问权限,否则则隐藏/阻止访问。

阅读文档后,我们认为我们已经正确设置了它,但是在验证时仍然出现此错误。

http://newui.proloop.com/dav/
rickatech
密码(不用担心,这里没有什么有价值的东西)

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();

我也在 StackOverflow 上发布了此问题,因为我不确定这是编码问题还是服务配置问题。 https://stackoverflow.com/questions/43060444/webdav-sabre-io-php-enabling-group-methods-throwing-errors

sabre.io 有支持论坛,但我觉得 StackExchange 的人们可能对此有更深入的了解。 https://groups.google.com/forum/#!topic/sabredav-discuss/MSSjwccjuP8

在此处输入图片描述 在此处输入图片描述

答案1

所以最终我们只是编写了我们自己的自定义集合处理程序,它根据我们管理组/项目成员资格的一些表检查当前登录的用户。

sabre.io 并没有真正展示出这有多么简单,所以我们花了很多时间尝试查看是否已经有最佳实践,但找不到,所以我们只好自己编写了一个,而且效果很好。

相关内容