API version: 0.3.0

---

# Handing out access

### Pointer relations and grant relations

The table above describes **pointer relations**, which is every relation except the ones listed below. A pointer
relation belongs to its **start** node: it points from something the user may change to something the user may merely
read. This allows, for example, an external user with read access to someone else's tree to attach their own notes to
it, without the owners of the tree being informed, being able to see the notes, or being able to remove them.

**Grant relations** are `OWNS`, `IS_IN_GROUP` and the `HAS_X_ACCESS` relations, including `HAS_GOVERN_ACCESS`. They are
statements about their **end** node, as they confer rights over it. Therefore they follow different rules than the table
above, and both of their nodes matter, in different ways. To create a grant relation `(recipient)-[:HAS_X_ACCESS]->(element)`
the user needs:

- **`HAS_GOVERN_ACCESS` to the element** (or ownership), i.e. the permission to hand out access to it at all. Without
  it, no one may share an element, however much access they have.
- **The access which is handed out**, i.e. `HAS_X_ACCESS` for `X` (or ownership). `OWNS` and `IS_IN_GROUP` hand out
  everything, so they require all access types, including `HAS_GOVERN_ACCESS`. A user can only pass on what they hold.
- **Read access to the recipient** (the start node). The user does not need create access to the recipient, as handing
  out access does not create anything inside of it. `OWNS` is the exception: it places the element inside of the start
  node and therefore requires create access to it, as other relations which are created by users do.
- Both accesses have to be **unconditional**: a path which contains a condition (`onLabel`, `onParentLabel`,
  `onState`, `onCreatedByUser`) is not good enough, unless a parallel path without conditions exists - the lowest link
  in a path counts, the best path overall wins.
- `OWNS` relations to `Token` elements are always refused, as tokens are owned by their user only.
- `HAS_STATE` relations additionally need update access to their start node, as they change which conditional grants
  apply to it.

Editing and deleting grant relations has its own rules, as the recipient and the element's governors have different
interests:

| Operation               | Allowed for                                                                                                                                                                                                            |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Update (`PATCH`, `PUT`) | Users who can see the relation and meet the creation rules above (`HAS_GOVERN_ACCESS` and the granted access, unconditional). The recipient can not edit their own grant by default, as editing may remove conditions. |
| Delete (`DELETE`)       | Users who can delete the start node, as for every relation, **and** users who can see the relation and hold `HAS_GOVERN_ACCESS` to the end node.                                                                       |

> **ℹ Recipients can delete their own grants**
>
> Users have full access to their own user node, so recipients can give up access and leave groups without help from
> others, e.g. by deleting their `IS_IN_GROUP` relation, as long as they can see the relation, i.e. read both of its
> nodes. A recipient who holds `HAS_GOVERN_ACCESS` can also "move" a grant to a node they control, by creating a
> parallel relation and deleting the original one.

Users can only see relations if they can read both of their nodes. Access to only one end, or to neither, does not
reveal the relation; the answer is `404` as if it did not exist.
Revoking or leaving does not cascade: access which somebody has passed on to others stays until it is revoked as well.

This way users can only pass on access they hold in full, can not widen a conditional grant they received into an
unconditional one, and only users who are meant to share an element can do so. `HAS_GOVERN_ACCESS` is not given by group
membership, see [writing to group nodes](/reference/access-model.md#writing-to-group-nodes).

### Handing out access, by example

The following tables are rendered from the cases which the end-to-end test `GrantMatrixTest` asserts against a static
dataset, so they always show the verified behavior. Every row is one request: the giver holds the listed access to the
element, can read the recipient, and tries to create the given relation.
`UPDATE` stands for the other access types, which behave the same way, with two exceptions: `HAS_SEARCH_ACCESS` and
`HAS_GOVERN_ACCESS` can not carry conditions, and handing out `HAS_GOVERN_ACCESS` needs nothing besides `GOVERN`.

| The giver holds                                            | and hands out                                          | Result  |
| ---------------------------------------------------------- | ------------------------------------------------------ | ------- |
| read access only                                           | `HAS_UPDATE_ACCESS` to a user                          | ➖ (403) |
| read access only                                           | `HAS_UPDATE_ACCESS` to a group                         | ➖ (403) |
| `UPDATE`                                                   | `HAS_UPDATE_ACCESS` to a user                          | ➖ (403) |
| `GOVERN`                                                   | `HAS_UPDATE_ACCESS` to a user                          | ➖ (403) |
| `GOVERN`, `UPDATE`                                         | `HAS_UPDATE_ACCESS` to a user                          | ✓ (201) |
| `GOVERN`, `UPDATE`                                         | `HAS_UPDATE_ACCESS` to a group                         | ✓ (201) |
| `GOVERN` through a group, `UPDATE` through a group         | `HAS_UPDATE_ACCESS` to a user                          | ✓ (201) |
| `GOVERN`, `UPDATE` through a group                         | `HAS_UPDATE_ACCESS` to a user                          | ✓ (201) |
| `GOVERN`, `UPDATE` (conditional)                           | `HAS_UPDATE_ACCESS` to a user                          | ➖ (403) |
| `GOVERN`, `UPDATE` (conditional)                           | `HAS_UPDATE_ACCESS` to a group                         | ➖ (403) |
| `GOVERN`, `UPDATE` (conditional) through a group           | `HAS_UPDATE_ACCESS` to a user                          | ➖ (403) |
| `GOVERN`, `UPDATE` (conditional), `UPDATE` through a group | `HAS_UPDATE_ACCESS` to a user                          | ✓ (201) |
| ownership                                                  | `HAS_UPDATE_ACCESS` to a user                          | ✓ (201) |
| ownership                                                  | `HAS_UPDATE_ACCESS` to a group                         | ✓ (201) |
| `GOVERN`, `UPDATE`                                         | `HAS_UPDATE_ACCESS` with condition `onLabel` to a user | ✓ (201) |
| `GOVERN`, `UPDATE` (conditional)                           | `HAS_UPDATE_ACCESS` with condition `onLabel` to a user | ➖ (403) |

Adding a user to a group (`IS_IN_GROUP`) hands out everything, so it needs every access type to the group:

| The giver holds                                                                   | and hands out           | Result  |
| --------------------------------------------------------------------------------- | ----------------------- | ------- |
| `CREATE`, `UPDATE`, `DELETE`, `SEARCH`, `GOVERN`, `EXECUTE`                       | `IS_IN_GROUP` to a user | ➖ (404) |
| `READ`, `UPDATE`, `DELETE`, `SEARCH`, `GOVERN`, `EXECUTE`                         | `IS_IN_GROUP` to a user | ➖ (403) |
| `READ`, `CREATE`, `DELETE`, `SEARCH`, `GOVERN`, `EXECUTE`                         | `IS_IN_GROUP` to a user | ➖ (403) |
| `READ`, `CREATE`, `UPDATE`, `SEARCH`, `GOVERN`, `EXECUTE`                         | `IS_IN_GROUP` to a user | ➖ (403) |
| `READ`, `CREATE`, `UPDATE`, `DELETE`, `GOVERN`, `EXECUTE`                         | `IS_IN_GROUP` to a user | ➖ (403) |
| `READ`, `CREATE`, `UPDATE`, `DELETE`, `SEARCH`, `EXECUTE`                         | `IS_IN_GROUP` to a user | ➖ (403) |
| `READ`, `CREATE`, `UPDATE`, `DELETE`, `SEARCH`, `GOVERN`                          | `IS_IN_GROUP` to a user | ➖ (403) |
| `READ`, `CREATE`, `UPDATE`, `DELETE`, `SEARCH`, `GOVERN`, `EXECUTE`               | `IS_IN_GROUP` to a user | ✓ (201) |
| `READ`, `CREATE`, `UPDATE` (conditional), `DELETE`, `SEARCH`, `GOVERN`, `EXECUTE` | `IS_IN_GROUP` to a user | ➖ (403) |
| ownership                                                                         | `IS_IN_GROUP` to a user | ✓ (201) |
| membership only                                                                   | `IS_IN_GROUP` to a user | ➖ (403) |

`OWNS` needs every access type to the element, and create access to the new owner:

| The giver holds                                                     | and hands out    | Result  |
| ------------------------------------------------------------------- | ---------------- | ------- |
| `READ`, `CREATE`, `UPDATE`, `DELETE`, `SEARCH`, `GOVERN`, `EXECUTE` | `OWNS` to a user | ✓ (201) |
| `READ`, `CREATE`, `UPDATE`, `DELETE`, `SEARCH`, `GOVERN`, `EXECUTE` | `OWNS` to a user | ➖ (403) |
| `READ`, `CREATE`, `UPDATE`, `DELETE`, `SEARCH`, `EXECUTE`           | `OWNS` to a user | ➖ (403) |
| ownership                                                           | `OWNS` to a user | ✓ (201) |

---

Home: [Ember Nexus API docs](/index.md)

Full site map: [llms.txt](/llms.txt)

Previous: [Access to nodes and relations](/reference/access-model/access-to-elements.md)

Next: [Conditional access](/reference/access-model/conditional-access.md)
