Keeweb: [Feature request] OneDrive and WebDav syncronisation

Created on 3 Nov 2015  ·  31Comments  ·  Source: keeweb/keeweb

Can you add OneDrive and WebDav syncronisation, please?

enhancement storage ux

Most helpful comment

:smiling_imp: Finally I got it working with ownCloud (thanks this this manual).
My final Apache config (.htaccess):

Header always add Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Headers "origin, content-type, accept, authorization, if-match, destination, overwrite"
Header always set Access-Control-Expose-Headers "ETag"
Header always set Access-Control-Allow-Methods "GET, HEAD, POST, PUT, OPTIONS, MOVE, DELETE, COPY, LOCK, UNLOCK"
Header always set Access-Control-Allow-Credentials "true"

RewriteEngine on
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ blank.html [R=200,L,E=HTTP_ORIGIN:%{HTTP:ORIGIN}]

All 31 comments

I agree, this is important. Alternative storage providers (OneDrive, GDrive and maybe webdav and url sync) will be added after Dropbox sync is completely finished.

+1 I look forward to WebDAV and url sync :)

+1 WebDav

+1 WebDav ( = OwnCloud and SeaFile sync support)

+1 WebDav

Also throwing out SmartFile sync support would be great as well.

:sparkles: :tada:
First WebDAV implementation is done in 3cdc6b2cb9ba4856543984d3e222c6d9846a5c5e (develop branch)
I've tested only the main case: add/open/save, and only on my webdav server
You can preview the changes at https://beta.keeweb.info (more... → WebDAV)
If there are any troubles with your environment, please let me know :gift:

Example server headers config:

Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: origin, content-type, accept, authorization, if-match, x-requested-with
Access-Control-Expose-Headers: ETag
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, HEAD, POST, PUT, OPTIONS
  • server must support CORS, this will automatically make it not compatible with public services, e.g. yandex.disk: there's no way to resolve it
  • server should support ETag but this is not required: if ETags are not supported, Last-Modified date will be compared (it's not atomic but will work for most of cases)

    • OR

  • if ETags are absent, Last-Modified dates must be supported on both GET and POST requests
  • server doesn't need to support WebDAV-specific features, just basic HTTP methods are required

:boom: If something doesn't work for your setup (especially auth), please contact me. Testing at early stage is very appreciated for this feature: there will be UX and engine changes in v1.1 but interaction and server requirements will remain the same, unless anyone finds them wrong.

Can you please provide a beta package for public download? Or should we test with the beta version hosted on your server?

https://beta.keeweb.info/index.html - this is the single file you need, it can be hosted in any environment

Testing the beta against owncloud 9.0, using Apache and the built-in Sabre dav implementation, and it returns 501 errors when trying to write/sync. Auth and reading the kdbx works fine though. Most likely an issue for the owncloud folks to tackle? According to docs, Apache and Sabre supports CORS and ETag, and I've added the headers listed above.

{"reqId":"LHPYtF0zanrQUTr3E3Za","remoteAddr":"xx.xxx.xxx.xx","app":"webdav","message":"Exception: {\"Message\":\"HTTP\\\/1.1 501 There was no handler found for this \\\"POST\\\" method\",\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\NotImplemented\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(248): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#1 \\\/var\\\/www\\\/owncloud\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(55): Sabre\\\\DAV\\\\Server->exec()\\n#2 \\\/var\\\/www\\\/owncloud\\\/remote.php(138): require_once('\\\/var\\\/www\\\/ownclo...')\\n#3 {main}\",\"File\":\"\\\/var\\\/www\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php\",\"Line\":462,\"User\":\"testing\"}","level":4,"time":"2016-03-12T22:26:01+00:00"}

@agentdr8 thanks, I got it, we should upload files with PUT/MOVE/DELETE, instead of POST. I'll implement this today.

@agentdr8 what was your ownCloud config? I've changed saving flow, now it calls:
HEAD → PUT (.tmp) → HEAD → MOVE (.tmp) → HEAD
This is working for my Apache and some WebDAV providers, but when I try co connect to ownCloud (I've downloaded OVA for Virtualbox from their website), I always get 401 Unauthorized on OPTIONS preflight request. What was your CORS config?
I've uploaded new build to https://beta.keeweb.info, please check if it's working for you now.

Just tested the implementation on Apache WebDAV, Seafile, ownCloud and Yandex.Disk: everything is working from the Desktop app but the web app requires CORS setup.

This is working for my Apache and some WebDAV providers, but when I try co connect to ownCloud (I've downloaded OVA for Virtualbox from their website), I always get 401 Unauthorized on OPTIONS preflight request. What was your CORS config?
I've uploaded new build to https://beta.keeweb.info, please check if it's working for you now.

The new build works great! No more 501 errors. As for owncloud 9, it was installed via PPA (on ubuntu 14.04), and the headers you posted were added to the .htaccess in /var/www/owncloud:

Header set X-Content-Type-Options "nosniff"
Header set X-XSS-Protection "1; mode=block"
Header set X-Robots-Tag "none"
Header set X-Frame-Options "SAMEORIGIN"
Header set X-Download-Options "noopen"
Header set X-Permitted-Cross-Domain-Policies "none"
Header set Access-Control-Allow-Origin: *
Header set Access-Control-Allow-Headers: "origin, content-type, accept, authorization, if-match, x-requested-with"
Header set Access-Control-Expose-Headers: ETag
Header set Access-Control-Allow-Credentials: true
Header set Access-Control-Allow-Methods: "GET, HEAD, POST, PUT, OPTIONS"
SetEnv modHeadersAvailable true

I'm not sure how the Directory/Virtualhost is configured in the OVA, but this is what I have in my Apache config for owncloud:

    <Directory /var/www/owncloud>
            Options Indexes FollowSymLinks
            AllowOverride All
            Allow from all
            Require all granted
            Satisfy Any
    </Directory>

EDIT: I guess I spoke too soon; opening files via webdav worked on the previous beta build, without 401 errors. Since I already had setup webdav, the initial auth had already taken place. I closed the password file and tried to reopen it and the current build seems to be throwing the 401 for the HEAD requests:

xx.xxx.xxx.xx - testing [13/Mar/2016:13:07:23 -0700] "HEAD /owncloud/remote.php/webdav/latestKP.kdbx HTTP/1.1" 401 144 "https://testdomain.com/kw/index.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36"

Which request throws 401 error for you? I'm getting 401 on OPTIONS, as it doesn't send Authorization header.

Which request throws 401 error for you? I'm getting 401 on OPTIONS, as it doesn't send Authorization header.

After some more testing, it appears to only throw 401 errors for the HEAD request via Chrome. I tried closing and reopening the kdbx on Firefox and it works fine:

xx.xxx.xxx.xx - testing [13/Mar/2016:13:25:42 -0700] "HEAD /owncloud/remote.php/webdav/latestKP.kdbx HTTP/1.1" 200 144 "https://testdomain.com/kw/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0"
xx.xxx.xxx.xx - testing [13/Mar/2016:13:26:05 -0700] "HEAD /owncloud/remote.php/webdav/latestKP.kdbx HTTP/1.1" 200 144 "https://testdomain.com/kw/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0"
xx.xxx.xxx.xx - testing [13/Mar/2016:13:26:08 -0700] "GET /owncloud/remote.php/webdav/latestKP.kdbx HTTP/1.1" 200 101260 "https://testdomain.com/kw/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0"

@agentdr8

  • are you using login/password?
  • could you please copy error message from Chrome console?

I get the following using login+password:
localhost/:1 XMLHttpRequest cannot load http://XXX.XXX.XXX.XXX/owncloud/remote.php/webdav/kdbx/owncloud.kdbx. Response for preflight has invalid HTTP status code 401

It doesn't work for me in Firefox: same error.

@agentdr8

are you using login/password?
could you please copy error message from Chrome console?

Yep, username/password. Here's my Chrome console errors:

HEAD https://testdomain.com/owncloud/remote.php/webdav/latestKP.kdbx 401 (Unauthorized)
    f._request @ index.html:16
    f.stat @ index.html:16
    e.View.extend.applyConfig @ index.html:19
    _ @ index.html:1
    m @ index.html:1
    f @ index.html:1
    l.trigger @ index.html:1
    d.View.extend.apply @ index.html:18
    n.event.dispatch @ index.html:3
    r.handle @ index.html:3
index.html:13 2016-03-13T20:35:22.272Z [storage-webdav] Stat error https://testdomain.com/owncloud/remote.php/webdav/latestKP.kdbx 401 32ms

So, in network panel:

  1. OPTIONS request without credentials succeeds
  2. HEAD with authorization fails
    Is this correct?
    If not, I guess you have a file opened with previous version of keeweb which was dropping credentials. Please delete it and open with WebDAV button again.

:smiling_imp: Finally I got it working with ownCloud (thanks this this manual).
My final Apache config (.htaccess):

Header always add Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Headers "origin, content-type, accept, authorization, if-match, destination, overwrite"
Header always set Access-Control-Expose-Headers "ETag"
Header always set Access-Control-Allow-Methods "GET, HEAD, POST, PUT, OPTIONS, MOVE, DELETE, COPY, LOCK, UNLOCK"
Header always set Access-Control-Allow-Credentials "true"

RewriteEngine on
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ blank.html [R=200,L,E=HTTP_ORIGIN:%{HTTP:ORIGIN}]

If not, I guess you have a file opened with previous version of keeweb which was dropping credentials. Please delete it and open with WebDAV button again.

That was it. Even though I had cleared cache, it was still cached somewhere. Opened a private browsing instance and retried and it works fine in Chrome.

It seems that WebDav works! My config : nginx 1.9.12 ; sabre-katana webdav server,
part of nginx config that at last starts working:

location ~ ^(.+?\.php)(/.*)?$ {

    if ($request_method = 'OPTIONS') {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, HEAD, POST, PUT, OPTIONS, MOVE, DELETE, COPY, LOCK, UNLOCK';
            add_header 'Access-Control-Allow-Headers' 'Authorization,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Accept-Charset,X-Accept,origin,accept,if-match,destination, overwrite';
            add_header 'Access-Control-Expose-Headers' 'ETag';
            add_header 'Access-Control-Max-Age' 1728000;
            add_header 'Content-Type' 'text/plain charset=UTF-8';
            add_header 'Content-Length' 0;
            return 204;
    }
        try_files $1 = 404;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$1;
        fastcgi_param PATH_INFO $2;
        fastcgi_param HTTPS on;
        fastcgi_pass unix:/var/run/php5-fpm.sock;

            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, HEAD, POST, PUT, OPTIONS, MOVE, DELETE, COPY, LOCK, UNLOCK';
            add_header 'Access-Control-Allow-Headers' 'Authorization,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Accept-Charset,X-Accept,origin,accept,if-match,destination, overwrite';
            add_header 'Access-Control-Expose-Headers' 'ETag';
            add_header 'Access-Control-Max-Age' 1728000;

}

with nginx http_dav_module and nginx-dav-ext-module it also works fine !! Thank you !

beta application cannot read webdav file SECOND time
console log
(index):16 Uncaught TypeError: Cannot read property 'get' of undefinedf.storeOptsToFileOpts @ (index):16d.Model.extend.setFileOpts @ (index):16(anonymous function) @ (index):16(anonymous function) @ (index):15(anonymous function) @ (index):8(anonymous function) @ (index):8

Подтверждаю, повторно файл не открывается.

Sent with MailTrack
https://mailtrack.io/install?source=signature&lang=en&[email protected]&idSignature=22

2016-03-22 15:11 GMT+03:00 Rurik19 [email protected]:

beta application cannot read webdav file SECOND time
console log
(index):16 Uncaught TypeError: Cannot read property 'get' of
undefinedf.storeOptsToFileOpts @ (index):16d.Model.extend.setFileOpts @
(index):16(anonymous function) @ (index):16(anonymous function) @
(index):15(anonymous function) @ (index):8(anonymous function) @ (index):8


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
https://github.com/antelle/keeweb/issues/14#issuecomment-199783390

Fixed second open, thanks!

Thanks for fix, but there is new bug - authorisation info for webdav server (basic authorisation) get lost after some time (about 20 minutes)

How to repeat this? Open the app, add a wabdav db, add something, wait for 20min, save? It's ok for me. What are your auto-lock and auto-save settings? Could you please add logs from dev console?

Sorry, for non-informative comment. Timeout is not important. Voila:

0) this is self-hosted beta index.html

1) Enter webdav credentials and file password
2) do some changes = ok
3) exit file with exit icon
4) enter file again = ok
5) any changes --> browser standard window "enter login and password"
console output no error, just operation
2016-03-23T07:34:23.959Z [sync:lp] Saved to cache, saving to storage (index):13 2016-03-23T07:34:23.959Z [sync:lp] Save data to storage (index):13 2016-03-23T07:34:23.959Z [storage-webdav] Save:stat https://****.ru/***/**.kdbx (index):13 2016-03-23T07:34:23.975Z [storage-webdav] Save:https://****.ru/***/**.kdbx Wed, 23 Mar 2016 04:42:17 GMT 16ms (index):13 2016-03-23T07:34:23.976Z [storage-webdav] Save:put https://***.ru/***/.**.kdbx.1458718463959
6) enter right credential = not workind, same window again, cancel -> error 401 in console

Thank you! Fixed that.
It's because I've changed webdav password storage implementation: now it's impossible to get password from settings, without access to decrypted file contents.

OneDrive preview deployed to https://beta.keeweb.info :sparkles:

OneDrive integration works! Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

blsz picture blsz  ·  31Comments

adatum picture adatum  ·  34Comments

testgoofy picture testgoofy  ·  28Comments

alexandru picture alexandru  ·  27Comments

eligrey picture eligrey  ·  29Comments