Oihana PHP Arango

authorizeRelationFields.php

Table of Contents

Functions

authorizeRelationFields()  : array<string, mixed>|null
Drops the relation markers whose edge/join definition is denied by the request-scoped authorizer (definition-level gating, `AQL::REQUIRES` on the definition itself).

Functions

authorizeRelationFields()

Drops the relation markers whose edge/join definition is denied by the request-scoped authorizer (definition-level gating, `AQL::REQUIRES` on the definition itself).

authorizeRelationFields(array<string, mixed>|null $fields, array<string, mixed>|null $edges, array<string, mixed>|null $joins[, array<string|int, mixed> $init = [] ]) : array<string, mixed>|null

A relation is emitted by two parallel walks that must stay symmetric : the LET sub-query (buildVariables) and the projected key (aqlFields). When a definition declares AQL::REQUIRES and the authorizer denies it, the LET is not emitted — so the matching marker must also disappear from the projected fields, otherwise the RETURN would reference an unbound variable. This helper performs that field-side purge : it is applied at every point where a prepared fields array meets its edges/joins registries, right before buildVariables() / aqlFields() run on them.

Resolution mirrors buildVariables() : the definition is looked up in the registry under the field key, a string value being a one-hop alias to another registry entry. A marker without a resolvable array definition is left untouched (buildVariables skips it anyway — nothing to desynchronize).

The check itself is delegated to isAuthorized() with the whole definition (its AQL::REQUIRES key equals Field::REQUIRES), so the semantics are exactly the field-level ones : no marker → allowed, no authorizer → allowed (fail open), a list of subjects → logical OR. The definition-level gate COMPOSES with the field-level Field::REQUIRES (evaluated downstream) : either level can drop the relation.

The function is pure and idempotent : applying it twice — e.g. once on the LET walk and once on the projection walk of a wrapped reference — yields the same fields, which is precisely what keeps both walks symmetric.

Parameters
$fields : array<string, mixed>|null

The prepared query fields (normalized definitions).

$edges : array<string, mixed>|null

The edges registry paired with the fields.

$joins : array<string, mixed>|null

The joins registry paired with the fields.

$init : array<string|int, mixed> = []

The request-level init array (reads Arango::AUTHORIZER).

Tags
author

Marc Alcaraz (eKameleon)

Return values
array<string, mixed>|null

The fields with denied relation markers removed.

On this page

Search results