feat(sidecar): enforce per-user BasePath on all filesystem mutations

Folder create/rename/delete/move, photo move, heap convert, and file
rename now reject paths outside the caller's BasePath (403). Sources
resolved via PhotoPrism UIDs are re-checked in movePhotoFiles. The
USER_BASEPATHS reconciler also sets upload_path so client-app uploads
land inside the user's subtree.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-03 12:46:00 +02:00
parent 634abc2a95
commit 6cbabda86b
7 changed files with 122 additions and 8 deletions

View File

@@ -86,12 +86,15 @@ func reconcileUserBasepaths(ppDSN, originalsRoot string, mapping map[string]stri
// ACL kicks in even if the directory is created later.
}
// upload_path rides along with base_path so anything a client app
// uploads (WebDAV sync apps, PhotoPrism's own UI) lands inside the
// user's library subtree instead of the shared originals root.
res := db.Exec(`UPDATE auth_users
SET base_path = ?
SET base_path = ?, upload_path = ?
WHERE user_name = ?
AND COALESCE(base_path, '') <> ?
AND (COALESCE(base_path, '') <> ? OR COALESCE(upload_path, '') <> ?)
AND deleted_at IS NULL`,
path, username, path)
path, path, username, path, path)
if res.Error != nil {
slog.Error("user-basepath: update failed", "user", username, "err", res.Error)
continue