Skip to main content

Conditional access

Conditional access

The following optional properties can be set on HAS_X_ACCESS:

  • onLabel: Limits access to a specific type of nodes.
  • onParentLabel: Limits access to children of a specific type of nodes, i.e. to elements which are owned (OWNS) directly by a node with this label. The label of the element itself does not matter, use onLabel for it.
  • onCreatedByUser: Requires that the element was created by the current user, i.e. the element’s createdBy property equals the id of the user.
  • onState: Limits access to elements which currently have a given workflow state.

HAS_SEARCH_ACCESS and HAS_GOVERN_ACCESS can not carry these properties. Who may find an element is calculated in advance and stored in the search index, which is only updated when ownership, group membership or search access relations change, so conditions would silently go stale. Access which is handed out has to hold for the whole element, so a conditional HAS_GOVERN_ACCESS could never be used. Requests which set a condition on one of them are refused with 400.

Limiting access by workflow state

You can model workflows by creating your own State nodes and connecting an element to its current state with a HAS_STATE relation. Setting onState on a HAS_X_ACCESS relation to the id of a State node then restricts that access grant to elements which have that state set somewhere along their OWNS-chain:

Here the anonymous user only ends up with read access to Post 1, since it is the only element with the Active state set - Post 2 and the Blog node itself are not covered by the grant.

The check walks the OWNS-chain upward from the element being accessed to look for a matching HAS_STATE relation, so it is repeated for every element the grant would otherwise cover. Prefer setting the state as close as possible to the elements it should actually restrict, rather than on a distant ancestor, to keep this cheap.