Repository navigation
feat(media): add a WebDAV share as a media source - #430
Open
obelix58143 wants to merge 5 commits into
Open
obelix58143 wants to merge 5 commits into
obelix58143 wants to merge 5 commits into
Conversation
Adds WebDAV (Nextcloud, ownCloud, any WebDAV server) as a picker source in the 2.0 media source menu, next to Google Drive, Google Photos, Canva and Unsplash. - Browsing: a file browser dialog lists one folder at a time (sub-folders first, then images and videos; hidden and other files are left out) via GET media/webdav/browse. The listing is fetched server-side with PROPFIND Depth: 1; the browser only ever sees paths below the configured root. - Importing: a new arm in StoreMediaImportRequest turns a picked path into a RemoteFile for the existing ImportRemoteMedia job. The share credentials travel as a header through MediaImportHeaders, so they stay out of the queued job, the database and the cache - same as the Google Drive token. - Safety: paths with empty, "." or ".." segments, backslashes or control characters are rejected before any request; downloads are limited to the configured share host and still go through SafeHttpFetcher (a share on a private network needs TRYPOST_ALLOW_PRIVATE_NETWORK); redirects are not followed when listing; a non-multistatus answer (e.g. a login page) is an error, not an empty folder. - Configuration: WEBDAV_ENABLED (off by default), WEBDAV_URL, WEBDAV_USERNAME, WEBDAV_PASSWORD, WEBDAV_ROOT, WEBDAV_LABEL, plus a per-user rate limit for listings. - No thumbnails: files are behind credentials, so the dialog shows a list with type, size and date instead of proxying previews. Translations for all 16 locales. Tests cover the menu, disabled and incomplete configuration, listing order and filtering, request shape and encoding, path traversal, upstream failures, entries outside the root, the import download and that the password never reaches response, job, tables or cache. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rce-v2 # Conflicts: # app/Enums/Media/Source.php # app/Providers/AppServiceProvider.php # resources/js/components/posts/composer/MediaSourceMenu.vue # resources/js/types/index.d.ts # resources/js/types/media.ts # routes/app.php # tests/Unit/Enums/Media/SourceTest.php
Indonesian arrived with trypostit#501 after this branch last synced; it now carries the same six WebDAV strings as every other locale. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since trypostit#514 every import arm names the media types its pick may be, and the WebDAV arm had none, so importing from the share failed with a 500. The browser only lists images and videos, so those are the two types: a document on the share is refused even when its path is posted by hand (new test). Also puts the blank line back between the WebDAV block and the host overrides in both env examples. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
Updated for 2.1.0 — merged current What changed:
Checks on this head:
Docs are up as trypostit/trypost-docs#33 (replaces the closed #25). |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces #355, which was written against the pre-2.0 gallery and is closed. This one plugs into the 2.0
MediaSourcemenu and import pipeline instead of building its own.What it does
Adds WebDAV (Nextcloud, ownCloud, any WebDAV server) as a picker source next to GIPHY, Google Drive, Google Photos, Canva and Unsplash. Self-hosted teams often already keep their photos in a Nextcloud folder; this lets them pick from it in the composer without downloading and re-uploading.
GET media/webdav/browse, which runs aPROPFIND Depth: 1server-side. The browser only ever sees paths below the configured root.StoreMediaImportRequestturns a picked path into aRemoteFilefor the existingImportRemoteMediajob, limited to images and videos (types). Several selected files become one import each, like the other sources.Security
MediaImportHeaders, so — like the Google Drive token — they stay out of the queued job, the database and the cache (covered by a test that greps all three)..or..segments, backslashes or control characters are rejected before any request is made, so nothing can climb out of the root.SafeHttpFetcher. A share on a private network needsTRYPOST_ALLOW_PRIVATE_NETWORK, documented in.env.example.multistatus(a login page, say) is an error rather than an empty folder.Configuration
Off by default:
Plus a per-user rate limit for listings (
WEBDAV_REQUESTS_PER_MINUTE, default 60).Checks
tests/Feature/Media/WebdavMediaSourceTest.php): menu and label, disabled/incomplete config, listing order and filtering, request method/auth/encoding, path traversal, upstream failures (500, 401, redirect, non-XML), entries outside the root, the import download, a document refused by type, and credential hygiene.vue-tsc, ESLint clean; Prettier clean on the new component (the existing menu file was left as is).Docs: trypostit/trypost-docs#33.
🤖 Generated with Claude Code