Skip to main content

Roles and capabilities

Access to elements is controlled by the access model. 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 group.manage make users and groups readable.

Capabilities

A capability is a named permission which endpoints check. The following capabilities exist:

CapabilityMeaning
role.assignAssign, remove and list the roles of users.
user.manageRead and search all users, see reading users and groups.
group.manageRead and search all groups, see reading users and groups.
index.manageReserved, no endpoint checks it yet. Indices of schemas are managed with schema.manage.
schema.manageCreate, 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.createRun the search step text-embedding, 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.manage on the token, every User node can be read with GET /<uuid> and found by every search step (Elasticsearch, Cypher path queries, element hydration). With group.manage, the same applies to every Group node.
  • 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 _passwordHash and _roles stay 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 list of an element.

Roles

A role is a named set of capabilities, defined in the instance configuration:

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 registration. 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 (user:create --role, user:role:add, user:role:remove, user:role:list) and through the endpoints GET/POST /user/<uuid>/roles and DELETE /user/<uuid>/roles/<role>.

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 POST /register with the issuer register, once, when the account is created. Changing the configuration later does not affect existing users. user:create 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 POST /token or token:create --capability. 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.