Sections, roles and access for builders
Part 2, chapter 18. Access in Exponential is configured, not programmed: roles hold policies, policies can be limited (by section, class, subtree, state, language, siteaccess), and roles are assigned to users and groups. A builder can create a members-only area, an editors' workflow or a private intranet with these tools alone. The reference pages are Roles and policies and Sections.
The pieces
| Piece | What it is |
|---|---|
| Section | a label every object carries (Standard, Users, Media, Setup, Design in a new installation); used to limit policies and to pick designs |
| Object state | a second, independent label from a state group (for example locked or not locked) |
| Policy | permission to use a module, or one function of it (content/read, content/edit, user/login) |
| Limitation | narrows a policy: only Section Standard, only class Article, only below one node, only in one state |
| Role | a named set of policies |
| Assignment | a role given to a user or a user group, optionally limited to a section or a subtree |
A user has every policy of every role assigned to them or to one of their groups. Policies only add; there is no "deny".
Why visitors do not see everything
The default Anonymous role has content/read limited to Section Standard. Everything in other sections (user
accounts, media folders, setup objects) is invisible to visitors who are not signed in. That single limitation is the
model for every private area you build.
Worked plan: a members-only area
- Create a section
members(Setup > Sections): name "Members", identifiermembers. - Assign the section to the subtree of the members' area (on the section page, assign to a node; the objects below get the section).
- Create a role "Members read" with one policy: module
content, functionread, limitation Section = Members. - Assign the role to the user group "Members".
- Check: signed out, the area's pages answer "access denied"; signed in as a member, they show.
- Optional: give the area its own look with overrides matching
Match[section_identifier]=members.
No code was written, and the area is secure, because fetches and views apply the same policies: a list of the area's articles is empty for anonymous visitors.
Asking about access in templates
| Template | Answers |
|---|---|
$node.can_edit, $node.can_create, $node.can_remove, $node.can_read | may the current user do this to this node |
fetch( 'user', 'has_access_to', hash( 'module', 'content', 'function', 'edit' ) ) | may the current user use this function anywhere |
fetch( 'user', 'current_user' ) | the current user, with .is_logged_in |
{if $node.can_edit}
<a href={concat( '/content/edit/', $node.contentobject_id )|ezurl}>Edit</a>
{/if}Hiding a link is a courtesy; the policy is what protects. Never rely on a template condition alone for security. Role and policy operators added in 6.0 are described in Role and policy template operators.
Checking a user's access
./console exp:accesscheck --helpThe command answers what a user may do with a node or object and which limitation refuses it, which is the quickest way to understand an "access denied".
Rules
- Give roles to groups, not to single users.
- Keep a policy on every module (
*) for administrators only; the role list marks such roles in red. - A policy on the
rolemodule lets its users give themselves anything: treat it as administrator access. - New extension modules declare their own policy functions; grant them deliberately (Policy functions and access checks).
Related pages
- Previous: Content classes for builders
- Next: Workflows for builders
- Roles and policies, Sections, Object states
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.