Expand description
Role hierarchy and expansion logic
This module defines the built-in role hierarchy and provides utilities for expanding hierarchical roles.
Constants§
- LEADER_
LEVEL - Hierarchy level of the “leader” role.
- MODERATOR_
LEVEL - Lowest hierarchy level permitted to manage (remove / re-role) other members.
- ROLE_
HIERARCHY - The hierarchy itself and its expansion live in
cloudillo-typesso the auth adapters can mint role strings through the same code the token-refresh path uses — see that module for why. Role hierarchy for profile-level permissions Higher roles inherit all permissions from lower roles
Functions§
- can_
assign_ role - Whether an actor at
actor_levelmay assignrole. Leaders may assign any known role; everyone else is capped strictly below their own level. Unknown roles are never assignable. - can_
manage_ member - Whether an actor at
actor_levelmay manage (remove or re-role) a member attarget_level. Rule: the actor must be moderator+ and strictly outrank the target — except leaders, who may also manage peer leaders. - can_
manage_ member_ by_ roles - Whether an actor with
actor_rolesmay manage (remove / re-role) a member withtarget_roles. Convenience overcan_manage_member+highest_role_level. - expand_
roles - The hierarchy itself and its expansion live in
cloudillo-typesso the auth adapters can mint role strings through the same code the token-refresh path uses — see that module for why. Expands hierarchical roles from highest role to all inherited roles - expand_
roles_ preserving_ extras - The hierarchy itself and its expansion live in
cloudillo-typesso the auth adapters can mint role strings through the same code the token-refresh path uses — see that module for why. Expand the hierarchy portion ofrolesand append any non-hierarchy roles verbatim. - highest_
role_ level - Highest hierarchy level among the given roles; unknown roles are ignored. Empty / all-unknown ⇒ 0 (public).
- is_
leader - True iff
rolesreaches theleaderlevel — the bar for managing tenant-owned resources. The tenant owner carries the full hierarchy (build_tenant_owner_rolesin auth-adapter-sqlite); federated visitors and share-link tokens carry none. - parse_
roles - The single parser for comma-separated role strings, re-exported for core-side
callers. Empty segments must be dropped — see the definition for why.
Parse a comma-separated role list into the shape
AuthCtx::rolesexpects. - role_
level - The hierarchy itself and its expansion live in
cloudillo-typesso the auth adapters can mint role strings through the same code the token-refresh path uses — see that module for why. Hierarchy index of a single role, or None if unknown.