Skip to content

Add public asset house rules - #3

Merged
bryantgillespie merged 2 commits into
mainfrom
bry/public-assets
Oct 27, 2026
Merged

bryantgillespie merged 2 commits into
mainfrom
bry/public-assets

Conversation

@bryantgillespie

@bryantgillespie bryantgillespie commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Why

Team feedback: public read on directus_files exposes every file through /files and /assets. The skills had the folder-scoped recipe and the trap, but not the house rules around it, and they didn't say what happens on the core tier.

What

directus-access-control (recipes, router trap)

  • Two setups, both documented. Public API (browsers call Directus, the public policy grants scoped reads) or server-side only (backend-for-frontend: frontend server routes call Directus with a server token). A table gives when to pick each and what it costs. Either way, expose the fewest collections and fields.
  • Assets usually stay direct in both setups: serve them from /assets so image bytes don't go through, and get billed on, the frontend server.
  • One public folder, with subfolders at most two levels deep. The rule now covers the folder and its direct children: {"_or":[{"folder":{"_eq":"<id>"}},{"folder":{"parent":{"_eq":"<id>"}}}]}. Match the folder by id.
  • Short field list for public files (id,title,description,type,filesize,width,height). * exposes uploaded_by, filename_disk, and metadata, and photo EXIF can include GPS.
  • Core tier: neither the folder rule nor a field list is allowed, so public file read means every file. Only do it if nothing private goes in the File Library; otherwise proxy assets or license the instance.

directus-content-modeling

  • Public-facing file fields set options.folder to the public folder (the file, file-image, and files interfaces all support it), so uploads don't 403 on the live site.

directus

  • /assets note points to the scoped recipe.

Changeset: minor.

Verified against v12.5.1

  • directus_files.folder → directus_folders and directus_folders.parent → directus_folders (packages/system-data/src/relations/relations.yaml).
  • /assets checks read access on the file and serves it with any allowed field list (api/src/services/assets.ts).
  • Folder option exists on file, file-image, and files interfaces.
  • node scripts/validate.mjs --strict: 0 errors, 0 warnings.

The two-level folder rule couldn't be exercised end to end here: the eval instance is unlicensed, and core rejects custom rules.

@bryantgillespie
bryantgillespie merged commit 828944c into main Oct 27, 2026
1 check passed
@bryantgillespie
bryantgillespie deleted the bry/public-assets branch October 28, 2026 22:24
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