tasks table so that only members of a task’s project
can read it:
bijection/schema.ts
bijection/ directory. Bijection hands it the reads
it has to decide, and it answers each one:
bijection/access.ts
tasks, public or internal, query or mutation,
is checked against taskRead. A member listing their project’s tasks gets
them; anyone else gets an error.
What a rule decides
A table can carry three rules. Each one is an ordinary query you export.
A table without rules behaves exactly as before: any function can read and
write it.
How rules differ from checks in functions
- Rules run as the caller. Inside a rule,
ctx.auth.getUserIdentity()returns the identity of whoever called the function that is reading or writing. Rules build on authentication; they don’t replace it. - Rules read private inputs. The tables a rule lists in
readsare open to the rule even when the caller can’t read them. A membership table can decide access without being readable itself. - A refusal is an error, not a filter. When a rule refuses, the function
fails with
Read access was refused, and nothing it computed from the refused data is returned. The one exception is an index range in a query, which leaves out the individual rows the rule refuses. See What callers see. - Rules stay reactive. The rows a rule reads are dependencies of the query it decided, so granting or revoking a membership reruns the subscriptions it affects.
Rules decide reads made by your functions. Deployment administration is
separate: snapshot exports, streaming exports and function logs are available
to holders of the deployment’s administrative permissions and are not
filtered by your rules.
Declaring access once
Writing a rule per table by hand is repetitive once you have roles, teams and nested objects. The access model lets you declare types, permissions, roles and grants once and generates the read, disclosure and write rules for every table it covers. Access to business operations and approvals uses separate permissions, which you manage with thebijection permissions command.
Read Rules
Decide which rows and properties each caller can read.
Disclosure Rules
Decide where protected data may be copied.
Write Rules
Authorize every change before it commits.
Access Model
Roles, grants and restrictions that generate your rules.