Roles¶
With clearance.roles: every change to roles, and where a person's roles are read from.
RoleService
¶
Makes, changes and gives out roles, for one actor - None for the system.
create_role
¶
create_role(code: str, name: str, *, ceiling: Iterable[str] | None = (), bundles: Iterable[Group] = ()) -> Role
A new role. Nobody has it yet, so making it changes nobody's access;
but a ceiling other than "nothing" - None is none at all - is a
ceiling set, and needs role_ceiling_edit.
rename_role
¶
Renaming changes nobody's access, so even somebody holding the role may do it.
delete_role
¶
Delete role: whoever had it loses its starting bundles - and, when it
was limited, its ceiling, which needs role_ceiling_edit.
ceiling_of
¶
What role lets its holders have: permission names, or None for no ceiling.
set_ceiling
¶
What role lets its holders have from now on - None for no
ceiling at all. Needs role_ceiling_edit, and is refused to anybody
holding the role.
give_bundle
¶
Everybody with role starts with bundle - the actor must hold what it gives.
take_bundle
¶
Nobody with role starts with bundle any more.
assign
¶
Give person role: its starting bundles - which the actor must
hold - and its ceiling. When they are under a ceiling already and the
role would widen it, or lift it, that needs role_ceiling_edit.
unassign
¶
Take role from person. When it is limited, that lifts its
ceiling from them, and needs role_ceiling_edit.
RoleResolver
¶
Bases: ABC
Reads which roles people have.
AssignmentResolver
¶
AttributeResolver
¶
has_role
¶
Whether user has any of codes - whose job an act is, not whether it is allowed.
roles_of
¶
The codes of user's roles - read once per request, kept on them.