Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol handling error (DAVx)? #1153

Closed
syncgw opened this issue May 13, 2019 · 12 comments

Comments

Projects
None yet
4 participants
@syncgw
Copy link

commented May 13, 2019

Hi,
we implemented SabreDAV 3.2.2 and recognized DAVx has problems connecting.

<propfind xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav" xmlns:CARD="urn:ietf:params:xml:ns:carddav">
  <prop>
    <resourcetype/>
    <displayname/>
    <CARD:addressbook-description/>
    <CARD:addressbook-home-set/>
    <current-user-principal/>
  </prop>
</propfind>`

The only called function from SabreDAV server is `validateUserPass` resulting in data send back to client:

```xml <?xml version="1.0" encoding="UTF-8"?>
 <d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:card="urn:ietf:params:xml:ns:carddav">
   <d:response>
     <d:href>/sync.php/</d:href>
     <d:propstat>
       <d:prop>
         <d:resourcetype>
           <d:collection/>
         </d:resourcetype>
         <d:current-user-principal>
           <d:href>/sync.php/principals/t1@wb28.de/</d:href>
         </d:current-user-principal>
       </d:prop>
       <d:status>HTTP/1.1 200 OK</d:status>
     </d:propstat>
     <d:propstat>
       <d:prop>
         <d:displayname/>
         <card:addressbook-description/>
         <card:addressbook-home-set/>
       </d:prop>
       <d:status>HTTP/1.1 404 Not Found</d:status>
     </d:propstat>
   </d:response>
 </d:multistatus>`

(the 404 is wrong). Any help appreciated.
@DeepDiver1975

This comment has been minimized.

Copy link
Member

commented May 13, 2019

 <card:addressbook-description/>
         <card:addressbook-home-set/>

if these properties are not set you are missing the carddav plugins on your server implementations

$server->addPlugin(new Sabre\CardDAV\Plugin());

@syncgw

This comment has been minimized.

Copy link
Author

commented May 13, 2019

Hi,
these are set. https://play.google.com/store/apps/details?id=org.dmfs.carddav.Sync and https://play.google.com/store/apps/details?id=org.dmfs.caldav.lib work well. The difference in protocol handling is, that these apps splits reading user props and addressbook-home-set in two queries, but DAVx puts them into one query (I don't know if this is allowed according to protocol specs).

@DeepDiver1975

This comment has been minimized.

Copy link
Member

commented May 13, 2019

To which url are these requests triggered?
Maybe the carddav plugin is only registered to some sub path?

Hard to tell without knowing the code base

@syncgw

This comment has been minimized.

Copy link
Author

commented May 13, 2019

	// check for handler
	$hid = 0;
	$cnf = sgwConfig::getObj();
	$ena = $cnf->getVar(sgwConfig::ENABLED);
	if (($ena & sgwDS::CONTACT) && file_exists(sgwUtil::mkPath('dav/Contact.php')))
		$hid |= sgwDS::CONTACT;
	if (($ena & sgwDS::CALENDAR) && file_exists(sgwUtil::mkPath('dav/Calendar.php')))
		$hid |= sgwDS::CALENDAR;
	if (($ena & sgwDS::TASK) && file_exists(sgwUtil::mkPath('dav/Task.php')))
		$hid |= sgwDS::TASK;

// ----------------------------------------------------------------------------------------------------------------------------------
	// Extracted from "SabreDav\examples\groupwareserver.php"

	$authBackend      = sgwDAVUser::getObj();
	$principalBackend = sgwDAVPrincipal::getObj();
	$tree             = [];

	if ($hid & sgwDS::CONTACT) {
		$tree[] = new \Sabre\DAVACL\PrincipalCollection($principalBackend);
		$tree[] = new \Sabre\CardDAV\AddressBookRoot($principalBackend, sgwDAVContact::getObj());
	}

	// is task data store enabled?
	if ($hid & sgwDS::TASK) {

        // sub domain enables to task list synchronization?
        // task list synchronization forced?
	    if (($t = $cnf->getVar(sgwConfig::FORCE_TASKDAV)) && ($t == 'FORCE' || stripos($http->getVar('SERVER_NAME'), $t))) {
		    // disable calendar synchronization
            $hid &= ~sgwDS::CALENDAR;
            DbgWarn('Force task synchronization only'); //3
	    }

	    if ($hid & sgwDS::CALENDAR && $hid & sgwDS::TASK) {
	        $log = sgwLog::getObj();
   			$log->Msg(sgwLog::WARN, 19001);
   			$hid &= ~sgwDS::TASK;
	    } else {
    		$tree[] = new \Sabre\CalDAV\Principal\Collection($principalBackend);
     		$tree[] = new \Sabre\CalDAV\CalendarRoot($principalBackend, sgwDAVTask::getObj());
	    }

	    // store update enabled handler ID for this session
        $cnf->updVar(sgwConfig::ENABLED, strval($hid));
	}

	// is calendar data store enabled?
	if ($hid & sgwDS::CALENDAR) {
		$tree[] = new \Sabre\CalDAV\Principal\Collection($principalBackend);
		$tree[] = new \Sabre\CalDAV\CalendarRoot($principalBackend, sgwDAVCalendar::getObj());
	}

	// allocate server
	$wd = new \Sabre\DAV\Server($tree);

	// patch Sapi class => Sabre\HTTP\Sapi.php
	$wd->sapi = $this;
	$wd->httpRequest = self::getRequest();
	$wd->setBaseUri($http->getVar('SCRIPT_NAME'));

	// authentication plugin
    $wd->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend));

    if ($hid & sgwDS::CONTACT)
        $wd->addPlugin(new \Sabre\CardDAV\Plugin());
    if ($hid & (sgwDS::CALENDAR|sgwDS::TASK))
        $wd->addPlugin(new \Sabre\CalDAV\Plugin());

    // permission plugin
    $wd->addPlugin(new \Sabre\DAVACL\Plugin());
    // WebDAV sync plugin
    $wd->addPlugin(new \Sabre\DAV\Sync\Plugin());

    $wd->exec();

`

@syncgw

This comment has been minimized.

Copy link
Author

commented May 13, 2019

Hope code extract help to understand our SabreDAV server approach. Please focus on CardDav - the server processes CardDav and CalDAV (which we not removed in extract) both.

@syncgw

This comment has been minimized.

Copy link
Author

commented May 13, 2019

I just installed and tested 4.0.0-beta1 - same result: No \CardDAV\Backend\BackendInterface functions called. class sgwDAVContact extends \Sabre\CardDAV\Backend\AbstractBackend implements \Sabre\CardDAV\Backend\SyncSupport {

@DeepDiver1975

This comment has been minimized.

Copy link
Member

commented May 13, 2019

To which url are these requests triggered?

Can you answer this please?

@syncgw

This comment has been minimized.

Copy link
Author

commented May 13, 2019

To a local test-installation of our syncgw.com product.
Depth: 0 Content-Type: application/xml; charset=utf-8 Content-Length: 290 Host: 192.168.10.100 Connection: Keep-Alive Accept-Encoding: gzip User-Agent: DAVx5/2.4.0.1-ose (2019/04/05; dav4jvm; okhttp/3.12.1) Android/8.1.0 Accept-Language: en-US, en;q=0.7, *;q=0.5 User: t1@wb28.de Password: Eea98b%1 Query: PROPFIND /sync.php HTTP/1.1 Authorization: Basic ****
Is this sufficient?

@evert

This comment has been minimized.

Copy link
Member

commented May 13, 2019

I'm curious.. do you see anything else appear in the webserver's access log?

@evert

This comment has been minimized.

Copy link
Member

commented May 13, 2019

Oh actually... Clients can't ask for card:addressbook-home-set on any URL. It has to be on the principal. That's likely your problem.

@syncgw

This comment has been minimized.

Copy link
Author

commented May 13, 2019

Thank you for clarification - I hoped it's a client implementation problem, since we are very happy with SabreDAV.

@syncgw syncgw closed this May 13, 2019

@rfc2822

This comment has been minimized.

Copy link

commented May 13, 2019

DAVx⁵ queries various URLs for addressbook-home-set, including the principal URL. It deals with 404 responses, so this should not be a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.