Expand description
Per-page permission engine.
Three pieces:
PagePermission—(page_id, role_id, permission)grants stored incms_page_permission. Sites grant fine-grained actions per role per subtree.user_can—(user_id, page_id, action) → bool. Walks the page’s ancestor chain collecting grants; superusers short-circuit totrue.Action— the canonical set of action strings the engine recognizes. Stored as text so the framework’s permission system can interoperate via codenames if/when we expose them.
Permissions inherit down the tree: a grant on a page applies
to every descendant unless overridden by a closer grant. There are
no explicit denies — any matching grant in the chain returns
true.
Structs§
- Collection
Permission - One
(collection_id, role_id, permission)grant — the media collection analogue ofPagePermission. Same UNIQUE shape and same inheritance semantics (parent collection grants flow to children). - Page
Permission - One
(page_id, role_id, permission)grant. UNIQUE at the SQL layer so a role can’t be granted the same action twice on the same page.
Enums§
- Action
- Canonical action set the engine recognizes. Stored as text so authors can extend the surface without a schema change.
Functions§
- user_
can - Resolve
(user_id, page_id, action) → boolagainst the per-page permission table. Walks ancestors via thecms_page.pathmaterialized prefix and collects matching grants in one query. - user_
can_ in_ collection - Resolve
(user_id, collection_id, action) → boolagainst the per-collection permission table. Walks the collection’s ancestor chain (viaparent_id) and short-circuits totruefor superusers. - user_
can_ matrix - Resolve the full action matrix for a user on a page in one shot.
Useful for the admin form-state computation where every action
is checked together (so the page editor can disable Publish but
allow Edit, etc.). Returns a fresh HashMap with one entry per
action —
truewhen granted,falsewhen not. - user_
codenames - Resolve the full set of role codenames a user inherits via their
UserRolememberships. Used by the admin chrome to gate sidebar items + by handlers to enforce CRUD access against the permissions matrix. - viewable_
page_ ids - Which of
pages—(id, parent_id)pairs —user_idmay view: the setuser_canwithAction::Viewwould allow, in a bounded number of queries instead of one walk per page. For list views, so a listing never shows a row its detail view refuses.