[owncloud-devel] Checking for webdav url on preLogin hook

Josef Meile jmeile at hotmail.com
Mon Aug 17 10:00:05 GMT 2015


Dear developers

I developed an app called: AgreeDisclaimer, see:
https://apps.owncloud.com/content/show.php?content=170844

Somebody just discovered that the app didn't allow the Dav sync for the
"contacts" and "calendar" apps. I figured out that the problem was that I'm
throwing a LoginException on my hook if the user didn't accept the
disclaimer on the login page. As a result, caldav and carddav couldn't do
the sync since they don't submit the checkbox on the login page.

My fix was adding this check:

$isDav = $this->request->getScriptName() === '/remote.php';
$disclaimerChecked = isset($_POST[$appName. 'Checkbox']);
if ( !$isDav && !$disclaimerChecked) {
    $message = $this->l10n->t('Please read and agree the disclaimer before
proceeding');
    throw new LoginException($message);
} else {
    //This means that the user either accepted the disclaimer
    //or the login page was called through a Dav client, so,
    //the login process will continue as usual
}

It will see if the user is using the webDav url:
http://<my_owncloud>/remote.php/...

You can see the full code here (I omit some parts, which aren't irrelevant
for the post):
https://github.com/jmeile/agreedisclaimer/blob/0.1.1/hooks/userhooks.php

So, I have this questions:
1) Is this check enough to avoid conflicts when using Dav?
2) Is there any better way of doing it?
3) Is there any other functionality that will conflict with my preLogin
hook?
4) I also saw on the docs that you can use this link:
     carddavs://example.org/remote.php/carddav
     to setup your dav synchronization. I tried that link, but it didn't
worked, so, I used:
     example.org/remove.php/carddav
     without "carddavs" and it worked. I guess it uses "https".
     Is there any support for the cardavs:// protocol on ownCloud? I could
also add a check like:

     If ($this->request->getServerProtocol() === 'carddavs://' {
         //Skip disclaimer validation
     }

     but I'm not sure if ownCloud will detect 'carddavs' as a server
protocol or perhaps everything just works through http:// and https://


Thanks

Best regards
Josef



More information about the Devel mailing list