Expand description
PageViewRestriction — gate published pages behind a password,
a login requirement, or a group membership check.
Restrictions inherit down the subtree: a restriction on /members
covers every descendant unless a descendant declares its own
restriction. The public renderer walks the ancestor chain at
request time and applies the nearest restriction it finds.
Four kinds (including #members):
password— anonymous visitor sees a prompt form, enters the password, gets a signed cookie that skips the prompt on subsequent visits.login— anonymous visitor redirected to/members/login?next=<url>. Any authenticated member/admin passes.groups— logged-in visitor must be a member of at least one of the named roles (rawrole_idmatch). Anonymous → /members/login; logged-in but not in any allowed group → 403.permission— logged-in visitor must hold at least one of the named permission codenames, resolved through the framework permission engine (has_any_perm_pool— superuser + per-user grant/deny baked in). This is the members-area gate; roles carry the codenames, admins assign the roles.
A page-type can also declare a login/permission restriction
for every page of that type (see TypeViewRestriction +
effective_or_type_for_page).
Structs§
- Access
Context - A resolve-once, in-memory oracle for “can this viewer see page X?”.
Built per render by
access_contextand reused for viewer-aware menu hiding and thecan_view/visibleTera helpers (so a template can guard any hand-written page link or nested list with the same protection the built-in menus apply). Holds the viewer’s resolved facts + every tenant view-restriction (page/subtree and per-type), soAccessContext::can_viewanswers with zero further queries. - Page
View Restriction - Type
View Restriction - A page-type-level view restriction declared by a
crate::page_type::PageTypeHandler::view_restrictionhook. OnlyLoginandPermissionkinds make sense at the type level (password+groupsneed per-page configuration). Applied only when a page carries no page/subtree restriction of its own. - Viewer
Facts - A viewer’s resolved access facts, independent of what is being guarded.
Enums§
Functions§
- access_
context - Build the per-render
AccessContextforviewer: load every tenant restriction (+ the restricted pages’ paths) and per-type restriction, and resolve the viewer’s codenames + role ids. Bounded, fixed number of queries; the viewer lookups are skipped entirely when nothing is gated or the viewer is a superuser. - denied_
page_ ids - Given a batch of pages and a viewer, return the subset of page ids
the viewer may not access — for viewer-aware menu hiding shared
by
auto_menuand the curated navigation resolver.pagesare(page_id, materialized_path, page_type_id)triples. Thin wrapper overaccess_context+AccessContext::can_view. - direct_
for_ page - Look up a direct (non-inherited) restriction on a single page.
- effective_
for_ page - Walk the page + every ancestor in path order (current page first, then parent, then grand-parent, …) and return the nearest restriction found. Used by the public renderer middleware.
- effective_
or_ type_ for_ page - The page’s effective restriction (own + inherited from any
ancestor), OR — when none is set anywhere on the branch — the
restriction its page type declares via
crate::page_type::PageTypeHandler::view_restriction. A concrete page/subtree restriction is more specific and always wins over the type-level one. - effective_
restrictions_ for - Bulk-resolve the effective page/subtree restriction for many pages
at once — for viewer-aware menu filtering, where calling
effective_for_pageper item would be an N+1 on every render. - only_
anonymous_ visible - Narrow a page query to what an anonymous visitor may see.
- type_
restriction_ for_ type - Resolve the type-level restriction for a page-type id, if the
handler declares one. Used by menu filtering to hide type-gated
pages; synthesizes a
PageViewRestrictionso callers share one predicate (viewer_satisfies). - viewer_
facts - Resolve a viewer’s permissions and roles.
- viewer_
satisfies - Decide whether a viewer may see a restricted item, using
pre-resolved viewer facts (so menu filtering avoids per-item
queries).
is_authed= a member/admin is signed in;is_super= superuser;perm_set= the viewer’s permission codenames (fromuser_permissions_pool);role_ids= the viewer’s role ids.