Skip to content

Sync folders over WebDAV, with app passwords - #20

Merged
ssenerg merged 1 commit into
mainfrom
webdav
Oct 25, 2026
Merged

ssenerg merged 1 commit into
mainfrom
webdav

Conversation

@ssenerg

@ssenerg ssenerg commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Sync apps and file managers can now reach goftp's files over WebDAV at /.dav/, so a folder on a computer or phone can stay in sync with it. Rules, homes, quotas and the trash all apply as they do on the site.

What's new

  • Sync page (/.sync/, in the account menu) shows the address to use (your home, if you have one) and your username. It makes app passwords, lists them with when each was created and last used, and revokes them. It also has setup steps for rclone, FolderSync, GoodSync, Mountain Duck/Cyberduck and Finder. Scripts can POST action=create|revoke and get JSON back.
  • App passwords are 24 base32 characters (120 bits), shown once and stored as SHA-256 hashes, with at most 20 per user. They sign in to WebDAV only (HTTP Basic). They stop working when revoked, when the user changes their password or gets a temporary one, and when the user is deleted. Migration 007_app_passwords.sql adds them.
  • WebDAV supports OPTIONS, PROPFIND (depth 0/1), PROPPATCH, MKCOL, GET/HEAD (with ranges), PUT, DELETE (into the trash), COPY, MOVE (Overwrite, Depth: 0), and LOCK/UNLOCK (advisory only).
    • Modification times are kept, from X-OC-Mtime on upload (rclone vendor=owncloud, ownCloud clients) and from PROPPATCH of getlastmodified, Win32LastModifiedTime or Cyberduck's lastmodified.
    • Homes report their quota (RFC 4331).
    • Finder's chunked uploads are taken via X-Expected-Entity-Length.
    • macOS ._* and .DS_Store files are accepted and dropped.

Fixes found while building it

  • A PUT with Content-Range used to replace the whole file with just that part. It is now refused with 400 (RFC 9110 §14.5), on the site too.
  • WebDAV sign-in failures count against the client's budget only after they fail, so a sync app's parallel requests are never refused with 429.
  • COPY/MOVE check the rights first, so a destination isn't trashed for a move that would then be denied. They also refuse to replace a folder that holds the source.
  • Outside /.dav/, WebDAV methods now get 405 instead of 501. Tests were updated to check 501 with an unknown method.

Limits (in the README)

  • Names starting with a dot aren't synced, since goftp hides them. The rclone steps exclude them.
  • WebDAV sends each file in one request. Behind a proxy that limits request size, larger files can't be uploaded this way: Cloudflare's limit is 100 MB on its Free and Pro plans, and nginx has client_max_body_size. Browser uploads are unaffected because they're sent in pieces. This matters for the yuhaha deploy behind the Cloudflare tunnel.

Testing

  • New tests:
    • internal/server/dav_test.go covers sign-in (sessions and account passwords refused, revoked or changed passwords, parallel requests, the limiter), PROPFIND, PUT/mtime/chunked/partial, GET, MKCOL, COPY/MOVE, DELETE, PROPPATCH, locks, home privacy and quotas, and the Sync page.
    • internal/auth/apppass_test.go covers app passwords on both the memory and Postgres stores.
  • go test -race ./... with Postgres passes on macOS, except TestLongNonASCIIPath, which fails only on macOS (on main too). Server and auth tests pass on Linux in golang:1.27.3-alpine. Linux amd64/arm64 and Windows builds pass.
  • End to end with rclone v1.75.2 against a local server:
    • bisync --resync, then changes on both sides (a local edit and delete, a site upload and delete, a non-ASCII name), all synced. Deletes went to the trash.
    • Modification times were kept exactly.
    • Over the quota, rclone got goftp's 507 explanation. rclone about showed the quota, and server-side moveto/copyto worked.
  • Sync page checked in a browser on desktop and phone widths.
  • Not tested with FolderSync, GoodSync or Mountain Duck themselves.

🤖 Generated with Claude Code

Sync apps (rclone bisync, FolderSync, GoodSync, Mountain Duck) and file
managers reach the site's files at /.dav/, with the same rules, homes,
quotas and trash. They sign in with HTTP Basic authentication and an app
password: made on the new Sync page (in the account menu), shown once,
stored as a SHA-256 hash, revocable one by one, and ended with every
password change. Wrong ones count against the client's sign-in budget
once they fail, so that a sync app's parallel requests are not refused.

Modification times are kept: from rclone's and ownCloud's X-OC-Mtime on
upload, and from PROPPATCH of getlastmodified or Windows'
Win32LastModifiedTime. PROPFIND reports homes' quotas (RFC 4331); locks
are advisory; macOS's ._ and .DS_Store files are taken and dropped.
Finder's chunked uploads carry X-Expected-Entity-Length, and must be
exactly that long. A PUT with Content-Range is refused rather than taken
as the whole file. COPY and MOVE check the rights to do so before what
they replace goes to the trash, and never replace a folder holding what
they move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ssenerg
ssenerg merged commit 37c1ad0 into main Oct 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant