Semantius Logo
DocsData CatalogPermissions and Roles

Permissions and Roles

On this page

Access in Semantius is decided inside the database. Each entity names the permission needed to read its records and the one needed to write them, and row-level security on the entity’s table checks the caller’s permissions on every request, whichever client sends it.

ConceptWhat it is
PermissionA name such as crm:read. It belongs to a module.
RoleA named set of permissions, assigned to users.
Direct grantA permission given to one user without a role.
Hierarchy entry”A includes B”: holding A grants B as well.

A user’s permissions are the permissions of all their roles, plus their direct grants, plus everything those include through the hierarchy, at any depth. A disabled user holds none. Roles are flat: a role cannot contain another role, so build broader access with the hierarchy instead. The users and agents who hold them are described under Users and Agents.

These are Semantius roles, kept as data. The PostgreSQL roles a request runs as are a separate thing, described under pg_semantius roles.

Permissions

A permission is what an entity names for reading and for writing its records. The hierarchy lets one permission include others, and a select_rule makes reading conditional.

Roles

A role bundles permissions for the users assigned to it. Every instance starts with the User and Administrator roles, and only holders of admin manage access.

When a change takes effect

A user’s permissions are worked out once per request, at its first check. A grant, a revoke, a role change or a disabled account applies from the user’s next request. Sign-in tokens carry no roles or permissions, so nobody has to sign in again.

API

CallWhat it does
/permissions, /roles, /role_permissions, /user_roles, /permission_hierarchyThe access model, through the create_*, read_*, update_* and delete_* tools of each, or postgrestRequest.
/user_permissionsDirect grants, through postgrestRequest.
/rpc/get_userinfoThe caller’s profile, roles, effective permissions (the hierarchy applied) and visible modules. The MCP tool getCurrentUser calls it.
/rpc/has_permissionWhether the caller holds p_permission_name. An unknown name answers false.

Errors

CodeMeaning
42501A refused write, or one of the guards (see its hint code). With hint code 90101, a call that requires a permission the caller lacks; the hint names the permission.
90203, 90205A role’s or hierarchy entry’s origin cannot change.
90204A system role’s slug cannot change.
90206catalog_role_code is write-once.
90210The hierarchy entry would close a cycle.
90211The hierarchy entry would make a chain longer than eleven entries.
23514A permission name or role slug breaks its pattern, or a hierarchy entry includes itself.
23505A role name, role slug, grant, assignment or hierarchy entry already exists.
23503, 23001A permission or role is still in use by an entity, a module or a RACI event.