Documentation Index
Fetch the complete documentation index at: https://cubed3-docs-conditional-row-level-access.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Use case
You want different row-level filters to apply to the same group depending on who the user is. For example:- Users in different regional groups should see only rows for their region.
- Admins should bypass row filters entirely, even when other policies restrict the same role.
access_policy by combining
conditions, row_level.allow_all,
and the OR semantics across policies that match the same group.
Data modeling
Region-based switching
Define one policy per region, and gate each policy with aconditions entry
that checks the userβs security context. Only the policy whose
condition evaluates to true contributes its row_level filter to the query β
the others are skipped.
In the following example, users in the analyst group see rows for their
region: members of the emea group are restricted to EMEA orders, and members
of the amer group are restricted to AMER orders.
row_level
itself a function of securityContext and returning different filters
depending on the caller:
Admin override with allow_all
To let admins bypass row-level filters that apply to a role, add a second
policy for the same group that grants row_level.allow_all
when securityContext.is_admin is true. Because policies that match the same
group are combined with OR semantics, the admin policy unlocks every row
regardless of the more restrictive analyst policy:
Composing boolean logic with conditions
conditions accept full boolean logic, so you can switch which row_level
applies based on combined checks against the security context and user
attributes. In YAML, use and, or, not, and parentheses inside
{ ... }. In JavaScript, use &&, ||, and !. Multiple conditions
entries on a single policy are combined with AND semantics; multiple
matching policies are combined with OR semantics.
In the following example, full-time analysts who are either admins or
owners and are not contractors get unrestricted row access; everyone else
in the analyst group falls back to the region-restricted policy above.
Result
With these policies in place:- Regional analysts see only rows for the region attached to their security
context, because only the policy whose
conditionsmatch contributes itsrow_levelfilter. - Admins see all rows, because the admin policyβs
row_level.allow_all: truecombines with the regional policy via OR semantics. - Users without any matching policy are denied access by default.