Roles and capabilities
Access to elements is controlled by the access . Roles and capabilities are independent of it: they control who may use instance-wide functionality, e.g. handing out roles. A capability does not grant access to elements, with one explicit exception: user.manage and make users and groups readable.
Capabilities
A capability is a named permission which endpoints check. The following capabilities exist:
| Capability | Meaning |
|---|---|
role.assign | Assign, remove and list the roles of users. |
user.manage | Read and search all users, see reading users and . |
group.manage | Read and search all groups, see reading users and . |
index.manage | Reserved, no endpoint checks it yet. Indices of schemas are managed with schema.manage. |
schema.manage | Create, change and reset schemas (PUT/PATCH/DELETE /schema/<type>), plan and run migrations, which create the indices of schemas, read the internal data of schema nodes and revisions, and grant access to them. |
embedding.create | Run the search step , which sends the text of the search to an embedding provider. Vectors of embeddings which the API calculates for elements do not need it. |
* | Wildcard, stands for every capability. |
Custom capabilities and partial wildcards like index.* are not supported.
Reading users and groups
Administrators can’t list or find users and groups through the graph, as nobody owns them. The capabilities user.manage and group.manage are therefore the explicit exception to “capabilities never grant access to elements”:
- With
user.manageon the token, everyUsernode can be read with and found by every search step (Elasticsearch, Cypher path queries, element hydration). Withgroup.manage, the same applies to everyGroupnode. - Only reading: changes and deletions of users and groups still need access through the graph, otherwise they answer with
403 Forbidden. - Only the nodes themselves: tokens stay visible to their user only, and the children of a user or a group, i.e. the data they own, are not covered.
- Internal properties like
_passwordHashand_rolesstay hidden, like for every other element. - Relations follow the normal rule, they are readable once both of their nodes are. With both capabilities, the memberships (
IS_IN_GROUP) between users and groups become readable: who belongs to which group, i.e. who shares data with whom, without access to the data itself. This is intended for administrators; hand out both capabilities together only to whom may know it. - The capabilities only extend what the token of the current request may read, never the access of other users, e.g. in the access of an element.
Roles
A role is a named set of capabilities, defined in the instance :
ember_nexus: roles: admin: capabilities: ['*'] role-manager: capabilities: ['role.assign']By default only the role admin with the capability * exists. Defining roles replaces the default completely, so a configuration without admin has no admin role. Role names consist of letters, digits, _ and -.
Role assignments
Roles are assigned to users. Every assignment records the role, its issuer and the time of the assignment. The issuer is cli for assignments through the CLI, api:user:<uuid> for assignments through the API and register for the default roles of the . The assignments are stored in the internal property _roles of the user, which is neither readable nor writable through the element endpoints. Like all properties they are part of backups: loading a backup restores the privileges it contains, so the backup:load command warns if the anonymous user holds roles. The anonymous user never has capabilities.
Roles can be handled through the CLI (, , , ) and through the endpoints / /user/<uuid>/roles and .
An actor may only assign or remove roles whose capabilities the actor holds itself. The check uses the capabilities of the actor’s user, i.e. it does not matter which capabilities the used token was restricted to.
Roles which are no longer defined in the configuration grant no capabilities. They stay assigned and can be removed.
Default roles of the registration
Instances which allow self-registration can hand out roles to every new user, e.g. a member role:
ember_nexus: roles: admin: capabilities: ['*'] member: capabilities: [] register: defaultRoles: ['member'] # default: []The roles are assigned by with the issuer register, once, when the account is created. Changing the configuration later does not affect existing users. does not assign them, it only assigns the roles given via --role.
Every default role must be defined in roles, otherwise the API refuses to start. If a default role contains * or role.assign, cache:warmup and cache:clear print a warning, which is part of the output of the container start: everyone who registers would get admin rights, even though tokens still have to name the capabilities explicitly.
Token capabilities
Tokens carry a list of capabilities, which is empty by default. It can be set when the token is created, through or . The list is write once: it can not be changed afterwards. The wildcard can not be requested, and a token can only be limited to capabilities the user holds at the time of creation.
The effective capabilities of a request are the intersection of the token’s capabilities and the current capabilities of the user, evaluated on every request. Removing a role from a user therefore takes effect immediately, for all tokens of the user. Because tokens have no capabilities by default, a leaked ordinary token of an admin can not be used to hand out roles.