Skip to main content
Version: v1 (Current)

Historical group-permissions design

This is the preserved pre-implementation design. It contains proposed contracts that differ from current code, including the absolute field-ceiling claim. Use Current group permissions for implementation behavior.

Attendee Group-Based Permissions — Design Spec

Status: design agreed, pre-implementation. Epic: EZ-2789 (stories EZ-2790 – EZ-2799). Working copy: docs/plans/2026-06-10-attendee-group-permissions.md (this file mirrors it).

This document defines the three-layer permission/scoping system for portal content: who can see a page, what objects its API surface can reach, and which rows/fields a given attendee receives — all driven by attendee group membership.


1. The three configuration layers​

Each layer has one owner and can only narrow what the layer above granted.

LayerOwnerArtifactAnswers
1. CapabilitiesPlugin developerplugin_page_versions.dependenciesWhat can pages built from this version do, against which model slices?
2. Object bindingProject adminproject_pages.dependency_listWhich concrete objects do this page's capability slots operate on?
3. Audience + fine-tuningProject adminpermission_rules (+ groups, scopes)Who can load the page, and which subset of the page scope / fields / abilities does each group get?

2. The inheritance chain​

Inheritance semantics​

  • PluginPageVersion → ProjectPage: the version's dependencies define the slots; the project page binds them via dependency_list. A page can never reach a model/ability its version didn't declare.
  • ProjectPage → ProjectPortalPage: rules attached to the ProjectPage are the defaults across all portals. If a ProjectPortalPage (portal link) has any rules of its own, they fully replace the page-level set for that portal (no merging between the two levels). effectiveRules() on the trait implements this in exactly one place.
  • The same chain applies to ProjectForm in place of ProjectPage (forms are the other model_type of project_portal_pages); Collection joins later.

3. Object definitions​

3.1 Capability slot — entry in plugin_page_versions.dependencies​

Developer-authored. One entry per slot.

{
"identifier": "social_stream", // slot name; "*" = project-wide scope, no binding needed
"model": "SocialStream", // target model
"permissions": ["view_all_posts"], // named abilities API endpoints check
"visibleFields": ["id", "name", "posts.caption", "posts.file_path"], // field CEILING
"cardinality": "multiple", // "single" | "multiple" (binding picker hint)
"allowTags": true // whether #tag bindings are accepted
}
  • A named identifier is a slot the admin will bind to concrete objects.
  • "*" is a project-wide scope for the model — unbound, grants its abilities against every instance in the project (e.g. view_all_streams → list all streams).
  • visibleFields is a hard ceiling: no lower layer can ever widen it.

3.2 Object binding — project_pages.dependency_list​

Admin-authored. Mixed array per slot; # prefix marks a ProjectTag, anything numeric is a model ID. Legacy scalar values remain valid (normalized to a one-element array).

{
"social_stream": [12, 1, "#tag-1", "@untagged"] // ids, tag members, untagged objects
}
  • An object satisfies the binding if its ID is listed, OR it carries any listed tag (via project_taggables), OR @untagged is listed and it carries no project tags. The same grammar (id / #slug / @untagged) is parsed by one matcher and applies identically in rule scope_tags.
  • #slug references are resolved to tag IDs at save time (authored text kept for display) so tag renames don't silently break bindings.
  • This resolved set is the page scope for the slot — the widest set of objects the slot's abilities can ever touch from this page.

3.3 Permission rule — permission_rules (+ pivots)​

Admin-authored via the permissions modal (entry points: plugin page config screen, portal links list, group dashboard tab).

{
"action": "allow", // "allow" | "deny"
"applies_to_public": false, // "Everyone" pseudo-group; guests match ONLY via this
"groups": [101], // permission_rule_groups pivot; OR within a rule
"nav_config": { "badge": "VIP" }, // values for the version's nav_fields_schema
"sort_order": 0, // merge + display order (NOT precedence)
"scopes": [ // permission_rule_scopes rows
{
"dependency_identifier": null, // NULL row = rule-wide default for all slots
"scope_tags": ["#tag-1"],
"visible_fields": null,
"dropped_abilities": []
},
{
"dependency_identifier": "social_stream", // per-slot override (replaces default for this slot)
"scope_tags": ["#tag-1", "#breakout-a"],
"visible_fields": ["id", "name", "posts.caption"],
"dropped_abilities": ["create_post"]
}
]
}

Per-slot resolution order: explicit slot row → rule default row (identifier = NULL) → pure inherit (no constraint, full page scope / full ceiling / full ability set).

Deny rules carry no scopes — they gate page access outright; tags/fields/ abilities are irrelevant to them.


4. Gate evaluation (can this attendee load the page at all?)​

Runs on: portal web page load, every portal API call carrying page context, and per nav item when building portalNavigation.

Notes:

  • Guests evaluate with an empty group set — they match only applies_to_public rules.
  • Denied = 404 on web and API (restricted pages are indistinguishable from nonexistent ones). The login redirect fires before the 404 check so guests on auth-required pages aren't 404'd for merely being logged out.
  • sort_order plays no role here — it is never precedence, only merge/display order.

5. Flattening — merging the matching allow rules​

Once the gate passes, the attendee's matching allow rules are flattened into a single compiled plan. All merges are most-permissive (union) — adding an attendee to another group can never reduce what they see.

DimensionPer-rule contributionMerge across matching rules
nav_configrule's nav_config objectshallow-merge in sort_order ascending; later keys overwrite earlier
Object scope (per slot)resolved scope_tags AND'd into the page scope; no constraint = full page scopeOR of all contributions
Fields (per slot)developer ceiling ∩ visible_fields; no override = full ceilingunion
Abilities (per slot)slot abilities − dropped_abilities; no drops = full setunion (a drop only sticks if every matching rule drops it)

Compiled query plan​

The evaluator produces, per slot (cacheable per (page, sorted group-ID set)):

{
"social_stream": {
"abilities": ["view_all_posts"],
"fields": ["id", "name", "posts.caption"],
"objects": {
"or": [ // one branch per matching allow rule
{ "pageScope": true, "and_tags": [7] }, // rule with #tag-1 (resolved id 7)
{ "pageScope": true } // inheriting rule = whole page scope
]
}
},
"*": {
"abilities": ["view_all_streams"],
"fields": ["id", "name", "stream_type"],
"objects": { "or": [ { "projectWide": true } ] }
}
}

Pseudo-SQL for the social_stream slot above:

-- pageScope = (id IN (12, 1) OR tagged tag-1)
WHERE ( (id IN (12,1) OR EXISTS tag(7)) AND EXISTS tag(7) ) -- rule 1 branch
OR ( (id IN (12,1) OR EXISTS tag(7)) ) -- rule 2 branch (inherit)

In your shorthand: { ability: { scopeOr: [pageScopeBranches], scopeAnd: [ruleTags] } } — group tags AND'd into each page-scope branch, the groups' branches OR'd together.


6. How the plan applies to API queries from the page​

Principal/context resolution (dual token)​

Only one Authorization header exists, so:

  1. Bearer resolves the principal: Attendee token → attendee; ProjectPortalPage token → page-only (guest); web sessions resolve the attendee via the Sanctum stateful cookie (bearer stays the page token there — unchanged).
  2. If the principal is an attendee, page context comes from the X-Portal-Page-Token header (already validated in PortalApiConfig and RequireAttendee; format-checked against header smuggling).
  3. Frontend (gxpPortalConfigStore): pageToken ref split from authToken; axios interceptor sends X-Portal-Page-Token on every call; Echo connectors and the multipart raw-axios path get the same treatment.

Parent/child (object + children) semantics​

Scope tags evaluate against the object graph:

  • Parent matches (ID-bound or tagged) → parent and all its children are in scope.
  • Only a child matches (e.g. a post tagged, its stream not) → the child is in scope and its parent becomes resolvable (show/nested routes work) but the parent is not listed in index responses; untagged siblings stay out.
  • Discovery path for child-only matches: per-model scoped-items routes — thin Orion child-level indexes (e.g. GET /social-streams/posts) returning all in-scope children across parents with parent references, each backed by the shared evaluator query scope. Keeps Orion search/filter/pagination and typed responses; a generic catch-all endpoint can be added later if model coverage lags.

Form endpoint enforcement (page-context requirement)​

Forms have three interaction surfaces today; enforcement differs:

SurfaceTodayNew requirement
API forms/{id}/responses (store/update/destroy)auth:sanctum, no page checkPage context required (page-token bearer or X-Portal-Page-Token); page must pass the gate AND reference the form (its model_id or in its dependency_list); else 404
API /quiz/{form}/*withoutMiddleware(auth:sanctum) — openSame page-context requirement; the page token becomes the auth for these routes
Web /register/{form} (show/submit/save-progress)Portal session stack, standaloneExempt from page context (pre-auth registration entry point), but the gate still runs with guest/attendee semantics if the form has rules — deny or missing public allow → 404

The portal frontend satisfies the page-context requirement automatically once the store sends X-Portal-Page-Token on every call; no plugin changes.


7. Worked example (end to end)​

Setup:

  • Version dependencies: social_stream slot (view_all_posts) + * slot (view_all_streams), both model SocialStream. Project has 3 streams; streams 12 and 1 exist, stream 9 is tagged tag-1.
  • Page dependency_list: { "social_stream": ["#tag-1"] } → page scope = stream 9.
  • One allow rule: { groups: [group1], scopes: [{ identifier: null, scope_tags: ["#tag-1"] }] }. No public rule.
ActorOutcome
GuestNo applies_to_public rule → gate fails → page hidden from nav, URL/API 404 (after login redirect if applicable)
Attendee, not in group1Gate fails (allow-list) → 404 everywhere
Attendee in group1Gate passes. GET /social-streams → all 3 stream objects (* slot). ?include=posts → posts only under stream 9 (social_stream slot: pageScope ∩ #tag-1). Fields capped per slot ceiling. Nav shows the page with flattened nav_config.

8. Guards, invariants, edge cases​

  • Deny always wins; no precedence field. sort_order is merge/display order only.
  • Fail-closed scopes: an allow rule whose scope references deleted tags/groups still gates access but contributes nothing to data scope — worst case an empty list, never leaked data. UI flags inert rules (no groups + not public).
  • Group deletion: pivot rows cascade; rule left with no groups and not public is inert and surfaced in the UI.
  • Tag rename: #slug references resolved to IDs at save time (binding and rule scopes both); authored text retained for display.
  • Caching: nav list stays cached unfiltered per portal; gate + flatten run post-cache. Attendee group IDs cached per attendee, invalidated on attendee_group changes. Compiled plans cacheable per (page, sorted group-ID set); invalidate on rule/binding/tag changes.
  • Performance budget: the evaluator runs on every portal API call — story 6 carries perf tests for pages with many slots/rules.
  • Field ceiling is absolute: rule visible_fields can only remove fields from the developer's visibleFields; never add.
  • Backwards compatibility: pages with zero rules behave exactly as today (requires_authentication + access codes only); legacy scalar dependency_list values keep working.

9. Resolved design decisions (formerly open items)​

  • Scoped-items endpoint: per-model thin Orion routes over a shared evaluator query scope (section 6). Generic catch-all deferred.
  • @untagged sentinel: included in v1, valid in both grammars (dependency_list bindings and rule scope_tags); rendered as a pinned, visually distinct system option in pickers. No @all sentinel — "inherit" (absence of constraint) already means full scope, and the UI renders that state explicitly rather than storing a redundant value.
  • Form endpoints: page context required on API form/quiz routes; web /register/{form} exempt but gate-evaluated (section 6 matrix).
  • Dependency-list mixed format ([id, '#tag', '@untagged']): owned by this epic's matcher story. A partial implementation exists inside an unrelated ticket — this work supersedes it; reconcile/replace that code during implementation.
  • EZ-2227 — Group Profile Pages: Tabbed Views with Auto-Creation Workflows (epic EZ-2250 Projects: Groups & Tags): converts Groups/Show.vue to a settings-driven tabbed layout (settings.enabled_tabs). This epic's Group Permissions tab (reverse lookup of permission_rule_groups) must register as "permissions" in that tab vocabulary — whichever ships first sets the pattern and the other adopts it. The permissions-rule count is also a cheap Overview-tab quick stat for EZ-2227. The two tickets are linked ("relates to") and each references the other in its description.