Test mode: paid plans aren't on sale yet, so nothing is charged. Every plan's limits apply.

← Docs

Fine-grained authorization

Nod answers "may this user do this to that object?" from relationships you write: Zanzibar-style authorization, compatible with OpenFGA's modeling language (the one Auth0 FGA uses). Each realm has one authorization model and its own relationship tuples.

The model

model
  schema 1.1
type user
type group
  relations
    define member: [user, group#member]
type folder
  relations
    define viewer: [user, group#member]
type document
  relations
    define parent: [folder]
    define owner: [user]
    define editor: [user, group#member] or owner
    define viewer: ([user, user:*, group#member] or editor or viewer from parent) but not blocked
    define blocked: [user]
ConstructMeans
[user, user:*, group#member]Who may be written directly: a user, every user, members of a group
ownerWhoever has another relation on the same object
viewer from parentWhoever has viewer on the object's parent
a or b, a and b, a but not bUnion, intersection, exclusion. Mixing or and and needs parentheses

Modules

A model can be written in modules, as OpenFGA's modular models (schema 1.2), so each product or team keeps its own part. Put the module files one after another in the one text you PUT (in any order), each starting with module <name>:

module core
type user
type organization
  relations
    define member: [user]
    define admin: [user]

module issue-tracker
extend type organization
  relations
    define can_create_project: admin
type project
  relations
    define organization: [organization]
    define viewer: member from organization

Conditions

A relationship can hold only under a condition, a CEL expression over typed parameters, as in OpenFGA:

type document
  relations
    define viewer: [user, user with office_hours, user with from_office]

condition office_hours(hour: int, until: int) {
  hour >= 9 && hour < until
}

condition from_office(ip: ipaddress) {
  ip.in_cidr("10.0.0.0/8")
}

Write a conditional tuple with the condition's name, and optionally some of its parameters:

{ "object": "document:plan", "relation": "viewer", "user": "user:alice",
  "condition": { "name": "office_hours", "context": { "until": 17 } } }

and pass the rest in the request's context:

{ "object": "document:plan", "relation": "viewer", "user": "user:alice", "context": { "hour": 10 } }

Through the management API

Grant a machine client the fga: scopes it needs (Management API): fga:admin sets the model, fga:write writes tuples, fga:read reads them, and fga:check checks.

curl -X PUT  $ISSUER/api/v1/fga/model -H "Authorization: Bearer $T" --data-binary @model.fga
curl -X POST $ISSUER/api/v1/fga/write -H "Authorization: Bearer $T" -H 'content-type: application/json' \
  -d '{"writes":[{"object":"document:roadmap","relation":"viewer","user":"group:eng#member"},
                 {"object":"group:eng","relation":"member","user":"user:alice"}]}'
curl -X POST $ISSUER/api/v1/fga/check -H "Authorization: Bearer $T" -H 'content-type: application/json' \
  -d '{"object":"document:roadmap","relation":"viewer","user":"user:alice"}'
# {"allowed":true}

Listing

How we know it's right

OpenFGA's own consolidated test suite (Apache-2.0) is in crates/fga/tests/data. On memory, PostgreSQL and TwilightDB, all 997 of its assertions pass: every Check, ListObjects and ListUsers one. Any failure fails the build.

OpenFGA's conditions suite (abac_tests.yaml, also Apache-2.0) runs the same way: all 335 of its assertions pass on all three stores.

ListUsers with wildcards follows OpenFGA's set expansion, not "everyone who passes Check". user:* is listed when a wildcard grants the relation. A named user is listed beside it only when a tuple path names them: through a union, a named branch; through an intersection, every operand admits them (a wildcard may) and one names them; through an exclusion, the base names them, or the excluded side names them without excluding them. So a public document whose other parent is a group lists user:* and that group's members, not every user the wildcard covers.