files: add per-user public /site + anonymous web surface

Add a third storage area, /site — each member's own public root, served
unauthenticated on the web at ~<name> alongside the shared /public.

Web file host (files.<host>) is no longer a login wall:
- GET /            -> directory of members' ~user sites (+ sign-in link)
- GET /~<name>/... -> anon read-only browse + clean file URLs of /site
- GET /public/...  -> anon read-only browse + clean file URLs of shared
                      area (fixes bare /public requiring login: the old
                      Caddy `handle_path /public/*` never matched /public)
Login is now optional and gates only private /me + writes. The anon
surface has no route into anyone's /me and safeJoin rejects traversal.

Usage gauge now sums the member-owned areas (/me + /site) instead of
/me alone; shared /public stays operator-managed and unmetered.

Caddy: route all of files.<host> to the Go manager. Docs + tests updated
(anon download/browse, traversal confinement, /site metering).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Anthony Ettinger 2026-06-26 00:49:38 +00:00
parent d1615ac817
commit e478da905f
8 changed files with 486 additions and 53 deletions

View file

@ -700,19 +700,19 @@ FILES_SITE="
${FILES_DOMAIN} {
encode zstd gzip
# Public file area — unauthenticated, read-only HTTP for the shared /public
# directory, so download links (e.g. extension .crx/.zip) work for everyone.
# Maps 1:1 to the SFTP path: a member who runs
# Everything is served by the agentbbs file-manager on loopback. It serves,
# all from the same virtual storage as SFTP:
# / public directory of members' ~user sites (no auth)
# /~<name>[/...] a member's public /site — anon read-only browse + files
# /public[/...] the shared public area — anon read-only browse + files
# (signed in) the member's private /me, their /site, and /public
# Clean URLs map 1:1 to the SFTP paths, so share links just work:
# scp dist.crx files@${FILES_DOMAIN}:/public/extensions/acme/
# gets the URL https://${FILES_DOMAIN}/public/extensions/acme/dist.crx .
# Everything else falls through to the auth'd web file manager below.
handle_path /public/* {
root * ${DATA_DIR}/files/public
header Cache-Control \"public, max-age=300\"
file_server
}
# Member web file manager (webmail-password login; /me + /public browsing).
# -> https://${FILES_DOMAIN}/public/extensions/acme/dist.crx
# scp index.html files@${FILES_DOMAIN}:/site/
# -> https://${FILES_DOMAIN}/~<name>/index.html
# The anon surface has no route to a member's private /me (see internal/files
# web tests); it is structurally read-only and area-confined.
reverse_proxy http://${FILES_WEB_ADDR}
}
"