Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/docs/permissions/permissions-matrix.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ flowchart TD
| 7 | **Field-Level Security** | Which fields is the user allowed to see/edit? |

<Callout type="tip">
**Performance:** For reads, steps 2–6 are compiled into a query filter (owner-match ∪ materialized shares, AND-ed with RLS) at query time, not evaluated record-by-record. By-id writes are verified with a pre-image check: the target row is re-read through the write-scope filter before the mutation, and a row the caller cannot read answers exactly what a missing id answers (`404 RECORD_NOT_FOUND`). A predicate (`multi: true`) update or delete matches only the rows the caller can read: a row the read door would not return is not written, not counted and not refused, and above 10 000 such rows the write is refused (`400 INVALID_FILTER`) rather than narrowed by a cut-off list. A caller whose read of the object is refused writes none of its records: its by-id and predicate updates and deletes are refused, whatever rows they address. This keeps security checks efficient even on tables with millions of rows.
**Performance:** For reads, steps 2–6 are compiled into a query filter (owner-match ∪ materialized shares, AND-ed with RLS) at query time, not evaluated record-by-record. By-id writes are verified with a pre-image check: the target row is re-read through the write-scope filter before the mutation, and a row the caller cannot read answers exactly what a missing id answers (`404 RECORD_NOT_FOUND`). A predicate (`multi: true`) update or delete matches only the rows the caller can read: a row the read door would not return is not written, not counted and not refused, and above 10 000 such rows the write is refused (`400 INVALID_FILTER`) rather than narrowed by a cut-off list. Under record sharing it is bounded further, by the rows the caller may write (owner depth and queue, plus edit shares for an update; a share never grants delete, ADR-0111 D3): a row the caller can only read through a read share is not written by a predicate write, even when an app `update` widener admits it, and the write answers no error; address that row by id alone to write it. A caller whose read of the object is refused writes none of its records: its by-id and predicate updates and deletes are refused, whatever rows they address. This keeps security checks efficient even on tables with millions of rows.
</Callout>

## See also
Expand Down
14 changes: 14 additions & 0 deletions content/docs/permissions/rls.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@ records, their access depth and the records shared with them, so an `update`
widener reaches **only rows the caller can already read**; everything else it
admits by predicate is still refused.

**Under record sharing, a predicate write is bounded by the write scope, not
the read scope.** When record sharing is composed (`@objectstack/plugin-sharing`),
a predicate (`multi: true`) `update` / `delete` on a `private` object writes only
the rows the caller may **write**: their own records, their access depth and
queue membership, plus **edit** shares for an `update` (a share never grants
`delete`, ADR-0111 D3). A row the caller holds only through
a **read** share is readable, and an app `update` widener admits it, but a
predicate write does not reach it: the row is left as it was and the write
answers no error. To write such a row, address it **by id alone**
(`where: { id }`, or the payload `id`): a by-id write is judged by id, and the
widener admits it as written. A `where` that carries a scalar `id` **beside
other keys** under `multi: true`, and an `id` that is falsy (`''`, `0`), run as
predicate writes and meet the same bound.

<Callout type="warn">
**Known limitation — an app-authored write widener does nothing on a
`private` object without a matching read grant.** To let a position edit
Expand Down
2 changes: 1 addition & 1 deletion content/docs/releases/v17/17-2.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ an intent decision no codemod may make for you:

| You wrote | Decide |
| :--- | :--- |
| `{ where: { id, …other } }` without `multi` | declare `multi: true` so the full `where` is honoured (the result becomes the matched count), or drop the extra `where` keys to keep an unconditional single-row write |
| `{ where: { id, …other } }` without `multi` | declare `multi: true` so the full `where` is honoured (the result becomes the matched count), or drop the extra `where` keys to keep an unconditional single-row write. Under record sharing the `multi: true` form is a predicate write, bounded by the caller's write scope: a row the caller holds only through a read share, admitted by an app `update` widener, is left unwritten with no error. To write that row, address it by id alone (`where: { id }`) ([details](/docs/permissions/rls)) |
| `data.id` ≠ `where.id` | make the two ids equal (or drop `where.id`) to address the row by the payload id, or remove `id` from the payload to address it by `where.id` |

⚠️ **Flow authors reach this through `update_record` / `delete_record` nodes**
Expand Down
Loading