resolve roles

This block is part of the data group and was last modified in core v15.0.2.

resolve roles v15.0.2

What a subject may do under a root, at a path below it, by a role model the entity defines: which doors a badge holder may open in a room of a building (path: building, room), what a team member may do in a project, or what a member may do in a channel of a chat server.

In pins 5
  • model value required

    the name of a roles model the entity has (its setting roles_model_{model}), e.g. facilities, projects or chat

  • root value

    the root's guid (a company, an org, a server); optional when path is given

  • path array

    scope ids from the root's first level to the leaf, e.g. [building, room]; empty is the root

  • member value

    a member document's guid

  • subject value

    the subject the member documents name, usually a user guid; default the run's socket's user

Out pins 8
  • success condition
  • member condition
  • member guid value
  • owner condition
  • staff condition
  • allowed object
  • root value
  • error value

Resolves a subject's permissions with a role model. A model is the entity's setting roles_model_{model} (JSON) and nothing else: none is built in, and an entity without that setting has no such model (MODEL_NOT_FOUND). It names the stores of roots, members, roles and scopes and the fields linking them, and how each permission is decided. A path is scope ids from the root's first level down to the leaf (company → building → room; org → team → project; server → channel); it must be that chain under the root, else nothing is allowed; empty is the root itself. Overrides apply root to leaf, the deepest level naming the scope deciding: by "lists" (roles list scope ids they allow and deny, "*" is every scope, explicit beats "*", higher rank wins, a deny wins a tie, the owner ignores denies) or by "entries" (roles carry [{type, enabled, scopes}], read base role first then by rank; the last entry naming the deepest named level, or covering every scope, wins; none means the model's allowed_when_unset; the owner and a root whose type allows everything allow everything, staff their staff_allowed set). A role marked by the model's role.held_by_flag_field is held by exactly the members whose member.held_flag is set. The model's gate permission, if it names one, must hold at a path before any other. Results are cached per node and every write to the model's stores is heard at once. Give model, and root, or a path whose leaf's document names its root; give member (a member document guid) or subject (default: the run's socket's user). member is false for a non-member, a member excluded by the model's flags (suspended, banned), or a member of another root; allowed then is {}. allowed holds every permission the model and the root's roles name, each false where the gate does not hold or the path is not the root's. error: MODEL_REQUIRED, MODEL_NOT_FOUND, MODEL_INVALID, ROOT_REQUIRED, ROOT_NOT_FOUND, SUBJECT_REQUIRED, PATH_INVALID, PATH_UNCHECKABLE, ROLES_NOT_ENABLED.

Version history

Introduced in v15.0.2.

  • v15.0.2: block added in this release.

Back to data Return to the main group to view all sub-groups Back to roles Return to the group to view all blocks within this group