Kizuna.roles
Declare the roles callers hold, as names or built from a permission catalog.
Kizuna.roles(names) declares the roles callers hold:
Put them on the identity whose callers hold them, under roles. Its guard returns role, one name or an array of them, and a route's roles in its auth is checked against it before the handler runs.
| Property | Description |
|---|---|
roles.names | The role names, in declaration order. |
roles.schema | A zod enum of the names, for a response that tells a client who it is. |
From a permission catalog
Kizuna.roles(permissions, definitions) builds the roles from a permission catalog, so a route can name the permission it requires instead of the role. Every entry is checked against the catalog, and 'all' means every permission declared:
A route's requires is checked against what the caller's role holds, or the subset the guard returns as permissions, and the handler reads the list under auth.member.permissions.
| Property | Description |
|---|---|
roles.permissions | The catalog the roles are built from. |
roles.definitions | Each role and what it holds, as declared. |
roles.of(role) | What one role holds, or the union for several. |
roles.holds(role, requires) | Whether the role holds every permission in requires outright. |
See Access Control for the walkthrough.