Skip to content

[5.x] Authorize relationship fieldtype data#14718

Merged
jasonvarga merged 10 commits into
5.xfrom
relationship-fixes
May 22, 2026
Merged

[5.x] Authorize relationship fieldtype data#14718
jasonvarga merged 10 commits into
5.xfrom
relationship-fixes

Conversation

@jasonvarga
Copy link
Copy Markdown
Member

@jasonvarga jasonvarga commented May 22, 2026

Relationship-style fieldtypes (Entries, Terms, Users, Assets, Structures, etc.) returned data to the CP without checking the user could view it. This scopes them to the user's permissions, using each resource's existing policy/permission — so super admins and existing grants are unaffected.

  • Listings return only the resources the user can view — a filtered (possibly empty) list, rather than erroring — based on the same policies the CP itself uses.
  • By-id resolution (including the field-meta/preload path) authorizes each item; unviewable or missing items return a redacted placeholder, with "unauthorized" and "not found" made indistinguishable so ids can't be probed.
  • Column metadata is no longer leaked either: listing/preload columns are derived only from collections/taxonomies the user can view, so a blueprint's field handles/labels aren't exposed for resources they can't access.

Frontend: unviewable selections render as a muted placeholder (value preserved, still removable) instead of the red "broken" state; also fixes a crash in the asset field's placeholder.

Behavior note: Entries/Terms listings previously returned a 403 when the user could view none of the configured collections/taxonomies. They now return an empty list, consistent with the rest of the picker.

jasonvarga and others added 5 commits May 22, 2026 10:36
Gates the relationship and assets fieldtypes so they no longer disclose
resources the requesting user cannot view. Listing now gates on the parent
container or the relevant permission (mirroring the CP listings); by-id
resolution authorizes each item and returns a redacted placeholder for
unauthorized or not-found ids. Covers the relationship, assets-fieldtype,
and field-meta (preload) endpoints.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Structures back onto collections and navs; gate each item through the
backing resource's policy (CollectionPolicy/NavPolicy) instead of a coarse
configure-collections-or-navs check, which both leaked across types and was
over-restrictive. Clarifies the AssetFolder dynamic-container case.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Unviewable or missing relationship and asset selections now render as a
muted, non-error placeholder with a tooltip covering both the deleted and
no-permission cases, instead of the red broken state. Also fixes a crash
where an unauthorized asset placeholder hit a TypeError in the asset field.
Frontend only; the uniform backend placeholder is unchanged so no existence
oracle is introduced.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jasonvarga jasonvarga marked this pull request as ready for review May 22, 2026 19:24
jasonvarga and others added 5 commits May 22, 2026 15:34
…ip listings

The relationship picker now returns an empty result set when the user lacks
access to a listing, matching its existing filter-to-viewable behavior,
instead of a 403 that surfaced as an error in the picker UI. Also ensures the
zero-viewable case does not expose columns from a blueprint the user cannot
view.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…load

Relationship preload derived listing columns from the configured collection's
blueprint without authorizing it, exposing column metadata via the field-meta
endpoint. Columns are now derived only from collections the user can view,
falling back to the default columns otherwise.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirrors the collection fix: term relationship columns are now derived only
from taxonomies the user can view, falling back to the default columns
otherwise.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jasonvarga jasonvarga changed the title [5.x] Authorize relationship & asset fieldtype data [5.x] Authorize relationship fieldtype data May 22, 2026
@jasonvarga jasonvarga merged commit 6bf773f into 5.x May 22, 2026
29 checks passed
@jasonvarga jasonvarga deleted the relationship-fixes branch May 22, 2026 20:52
jasonvarga added a commit that referenced this pull request May 22, 2026
This commit intentionally avoids trying to resolve frontend changes from PR #14718 - they are cosmetic and will come in a future commit.

# Conflicts:
#     resources/css/components/assets.css
#     resources/css/components/items.css
#     resources/js/components/fieldtypes/assets/Asset.js
#     resources/js/components/fieldtypes/assets/AssetRow.vue
#     resources/js/components/fieldtypes/assets/AssetTile.vue
#     resources/js/components/inputs/relationship/Item.vue
#     resources/lang/de/messages.php
#     resources/lang/de_CH/messages.php
#     src/Fieldtypes/Entries.php
#     src/Fieldtypes/Terms.php
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