dupondje / PHP-Push-2

Z-Push Fork With CalDAV/LDAP Support
GNU Affero General Public License v3.0
67 stars 24 forks source link

BackendCombined: Logon failed on BackendCalDAV #69

Open jangrewe opened 11 years ago

jangrewe commented 11 years ago

I've been using BackendIMAP with Dovecot for some time and am very happy with it, now i wanted to also add CalDAV and CardDAV via Baikal Server. The username and password are identical for both Backends, but for some reason the authentication fails to the CalDAV backend:

06/03/2013 22:11:52 [ 4330] [DEBUG] [jan@faked.org] -------- Start
06/03/2013 22:11:52 [ 4330] [ INFO] [jan@faked.org] Version='SVN-trunk-r1685' method='POST' from='192.168.0.41' cmd='Sync' getUser='jan@faked.org' devId='androidc1198121097' devType='Android'
06/03/2013 22:11:52 [ 4330] [DEBUG] [jan@faked.org] Used timezone 'Europe/Berlin'
06/03/2013 22:11:52 [ 4330] [DEBUG] [jan@faked.org] Including backend file: '/srv/www/php-push-2/backend/combined/combined.php'
06/03/2013 22:11:52 [ 4330] [DEBUG] [jan@faked.org] Including backend file: '/srv/www/php-push-2/backend/imap/imap.php'
06/03/2013 22:11:52 [ 4330] [ WARN] [jan@faked.org] /srv/www/php-push-2/backend/imap/config.php:49 Constant IMAP_SERVER already defined (8)
06/03/2013 22:11:52 [ 4330] [ WARN] [jan@faked.org] /srv/www/php-push-2/backend/imap/config.php:52 Constant IMAP_PORT already defined (8)
06/03/2013 22:11:52 [ 4330] [ WARN] [jan@faked.org] /srv/www/php-push-2/backend/imap/config.php:55 Constant IMAP_OPTIONS already defined (8)
06/03/2013 22:11:52 [ 4330] [ WARN] [jan@faked.org] /srv/www/php-push-2/backend/imap/config.php:61 Constant IMAP_DEFAULTFROM already defined (8)
06/03/2013 22:11:52 [ 4330] [ WARN] [jan@faked.org] /srv/www/php-push-2/backend/imap/config.php:64 Constant IMAP_SENTFOLDER already defined (8)
06/03/2013 22:11:52 [ 4330] [ WARN] [jan@faked.org] /srv/www/php-push-2/backend/imap/config.php:67 Constant IMAP_INLINE_FORWARD already defined (8)
06/03/2013 22:11:52 [ 4330] [ WARN] [jan@faked.org] /srv/www/php-push-2/backend/imap/config.php:70 Constant IMAP_USE_IMAPMAIL already defined (8)
06/03/2013 22:11:52 [ 4330] [ WARN] [jan@faked.org] /srv/www/php-push-2/backend/imap/config.php:75 Constant IMAP_EXCLUDED_FOLDERS already defined (8)
06/03/2013 22:11:52 [ 4330] [DEBUG] [jan@faked.org] Including backend file: '/srv/www/php-push-2/backend/caldav/caldav.php'
06/03/2013 22:11:52 [ 4330] [ WARN] [jan@faked.org] /srv/www/php-push-2/backend/caldav/config.php:48 Constant CALDAV_SERVER already defined (8)
06/03/2013 22:11:52 [ 4330] [ WARN] [jan@faked.org] /srv/www/php-push-2/backend/caldav/config.php:51 Constant CALDAV_PORT already defined (8)
06/03/2013 22:11:52 [ 4330] [ WARN] [jan@faked.org] /srv/www/php-push-2/backend/caldav/config.php:54 Constant CALDAV_PATH already defined (8)
06/03/2013 22:11:52 [ 4330] [ WARN] [jan@faked.org] /srv/www/php-push-2/backend/caldav/config.php:57 Constant CALDAV_PERSONAL already defined (8)
06/03/2013 22:11:52 [ 4330] [DEBUG] [jan@faked.org] Including backend file: '/srv/www/php-push-2/backend/carddav/carddav.php'
06/03/2013 22:11:52 [ 4330] [ WARN] [jan@faked.org] /srv/www/php-push-2/backend/carddav/config.php:48 Constant CARDDAV_SERVER already defined (8)
06/03/2013 22:11:52 [ 4330] [ WARN] [jan@faked.org] /srv/www/php-push-2/backend/carddav/config.php:51 Constant CARDDAV_PORT already defined (8)
06/03/2013 22:11:52 [ 4330] [ WARN] [jan@faked.org] /srv/www/php-push-2/backend/carddav/config.php:54 Constant CARDDAV_PATH already defined (8)
06/03/2013 22:11:52 [ 4330] [ WARN] [jan@faked.org] /srv/www/php-push-2/backend/carddav/config.php:57 Constant CARDDAV_PRINCIPAL already defined (8)
06/03/2013 22:11:52 [ 4330] [DEBUG] [jan@faked.org] Combined 3 backends loaded.
06/03/2013 22:11:52 [ 4330] [ WARN] [jan@faked.org] /srv/www/php-push-2/lib/default/filestatemachine.php:346 Illegal string offset 'version' (2)
06/03/2013 22:11:52 [ 4330] [DEBUG] [jan@faked.org] Request::ProcessHeaders() ASVersion: 14.0
06/03/2013 22:11:52 [ 4330] [DEBUG] [jan@faked.org] ZPush::CommandNeedsProvisioning(0): true
06/03/2013 22:11:52 [ 4330] [DEBUG] [jan@faked.org] FileStateMachine->GetState() on file: '/var/lib/z-push/7/9/androidc1198121097-devicedata'
06/03/2013 22:11:52 [ 4330] [DEBUG] [jan@faked.org] ASDevice data loaded for user: 'jan@faked.org'
06/03/2013 22:11:52 [ 4330] [DEBUG] [jan@faked.org] TopCollector(): Initialized mutexid Resource id #156 and memid Resource id #157.
06/03/2013 22:11:52 [ 4330] [DEBUG] [jan@faked.org] LoopDetection(): Initialized mutexid Resource id #159 and memid Resource id #160.
06/03/2013 22:11:52 [ 4330] [DEBUG] [jan@faked.org] ZPush::HierarchyCommand(0): false
06/03/2013 22:11:52 [ 4330] [DEBUG] [jan@faked.org] DeviceManager->ProvisioningRequired('395192331') saved device key '395192331': false
06/03/2013 22:11:52 [ 4330] [DEBUG] [jan@faked.org] ZPush::CommandNeedsAuthentication(0): true
06/03/2013 22:11:52 [ 4330] [DEBUG] [jan@faked.org] Combined->Logon('jan@faked.org', '',***))
06/03/2013 22:11:55 [ 4330] [DEBUG] [jan@faked.org] BackendIMAP->Logon(): User 'jan@faked.org' is authenticated on IMAP
06/03/2013 22:11:55 [ 4330] [ WARN] [jan@faked.org] BackendCalDAV->Logon(): User 'jan@faked.org' is not authenticated on CalDAV
06/03/2013 22:11:55 [ 4330] [DEBUG] [jan@faked.org] Combined->Logon() failed on BackendCalDAV
06/03/2013 22:11:55 [ 4330] [ INFO] [jan@faked.org] AuthenticationRequiredException: Access denied. Username or password incorrect - code: 0
06/03/2013 22:11:55 [ 4330] [ INFO] [jan@faked.org] User-agent: 'Android/4.2.2-EAS-1.3'
06/03/2013 22:11:55 [ 4330] [DEBUG] [jan@faked.org] ZPush::PrintZPushLegal()
06/03/2013 22:11:55 [ 4330] [ WARN] [jan@faked.org] IP: 192.168.0.41 failed to authenticate user 'jan@faked.org'
06/03/2013 22:11:55 [ 4330] [DEBUG] [jan@faked.org] LoopDetection->ProcessLoopDetectionTerminate()
06/03/2013 22:11:55 [ 4330] [DEBUG] [jan@faked.org] -------- End

The CalDAV and CardDAV backends work fine with Thunderbird/Lightning and the right extensions.

meirg commented 10 years ago

I was having this issue connecting to SabreDAV, it seems it was an issue with the digest authentication. I fixed this in caldav-client-v2.php in the DoRequest function where it said "TODO: add support for qop and related options" add the following after $A2:

        $qop = $digest_data['qop'];
        $nc = '00000001';
        $opaque = $digest_data['opaque'];

        $cnonce = substr('6346'.md5(time()),4,16); // This is just a random sort of thing, I made it up, not from anywhere.

        $authdig = 'Authorization: Digest username="' . $this->user . '", realm="' . $digest_data['realm'] . '", nonce="' . $digest_data['nonce'] . '", uri="' . $url . '", response="' . md5($A1 . ":" . $digest_data['nonce'] . ':'.$nc.':'.$cnonce.':'.$qop. ":" . $A2) . '"';

        $authdig .= ', opaque="'.$opaque.'"';
        $authdig .= ', qop='.$qop.', nc='.$nc;

        $authdig .= ', cnonce="'.$cnonce.'"';
        $headers[] = $authdig;

This is based off this wikipedia article: http://en.wikipedia.org/wiki/Digest_access_authentication

Hope this helps