Search code examples
mysqlauthenticationsabredav

SabreDav authentication fails


I started creating my own test server using SabreDav in a local environment and all worked just fine.

Now, I am trying to migrate my config to my production web server and I am experiencing all sorts of trouble with the PDO authentication as described here.

I successfully created my database and, without authentication, I am able to navigate principal nodes (meaning my DB connection is working fine).

When adding the server pdo authentication plugin, it keeps asking for the login/password, although I have used the default values, as if login/pwd were wrong.

I tested many scenarios and cannot figure out why it keeps preventing me from login - as I am quite sure login / pwd are correct!

Test scenario: see the nodes in myServer/server.php/principals/admin/ (admin being the default user created in the mysql scripts as found here).

Attempt 0: SUCCESS disable authentication in my server.php

$authBackend = new Sabre\DAV\Auth\Backend\PDO($pdo);
// -- comment out $authPlugin = new Sabre\DAV\Auth\Plugin($authBackend);
// -- comment out $server->addPlugin($authPlugin);

Attempt 1: FAIL using default configuration in my server.php fails and keeps prompting for password

$authBackend = new Sabre\DAV\Auth\Backend\PDO($pdo);
$authPlugin = new Sabre\DAV\Auth\Plugin($authBackend);
$server->addPlugin($authPlugin);

Attempt 2: FAIL forcing the default realm in server.php keeps prompting for password

$authBackend = new Sabre\DAV\Auth\Backend\PDO($pdo);
$authBackend->setRealm('SabreDAV');
$authPlugin = new Sabre\DAV\Auth\Plugin($authBackend);
$server->addPlugin($authPlugin);

Attempt 3: FAIL alternate method to forcing the default realm in server.php keeps prompting for password

$authBackend = new Sabre\DAV\Auth\Backend\PDO($pdo);
$authPlugin = new Sabre\DAV\Auth\Plugin($authBackend, 'SabreDAV');
$server->addPlugin($authPlugin);

Attempt 4: FAIL keep the same realm 'SabreDAV' and generate a different digest (actually, I made sure to use the exact same login/password as in my local server which works locally, but not on the web production server...)

$authBackend = new Sabre\DAV\Auth\Backend\PDO($pdo);
$authPlugin = new Sabre\DAV\Auth\Plugin($authBackend, 'SabreDAV');
$server->addPlugin($authPlugin);

IMPORTANT NOTE: It appears my production mysql DB stores encripted data - if this is the origin of the problem, is there a way to resolve the issue ?

Login window says ´A username and password are being requested by https://mywebsite.com. The site says: "SabreDAV"´.

Then when hitting escape, here is the error page:

<d:error>
    <s:sabredav-version>3.0.3</s:sabredav-version>
    <s:exception>Sabre\DAV\Exception\NotAuthenticated</s:exception>
    <s:message>No 'Authorization: Digest' header found. Either the client didn't send one, or the server is mis-configured</s:message>
</d:error>

I did set-up a digest in my server configuration, as I use the standard way described in tutorials:

$authPlugin = new Sabre\DAV\Auth\Plugin($authBackend, 'SabreDAV');

Solution

  • Credits to Evert for pointing me to the right direction using a .htaccess file at the server root that contains following code:

    RewriteEngine on
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]