Skip to main content

zanzibar-index

Zanzibar-style relationship-based access control (ReBAC) for Python, stored in SQLite or PostgreSQL through SQLModel. You write your permission model in a subset of the OpenFGA modelling language (schema 1.1, including and and but not), record relationships such as "alice is a member of eng", and ask questions such as "can alice view this document?" and "who can view it?". The package is not affiliated with Google or OpenFGA.

Two backends give the same answers with opposite cost models. The set engine stores only the raw tuples and computes each answer when you ask; the graph index stores every implied relationship ahead of time, so a check is a few indexed lookups and the work moves to writes.

Status: alpha, research code, no support promised. It is heavily tested but has never run in production, it has no performance target, and the API may change in any 0.x release. Issues and pull requests are welcome; answers are best-effort.

Install

pip install zanzibar-index              # SQLite
pip install "zanzibar-index[postgres]"  # adds psycopg2-binary for PostgreSQL

Python 3.13 or later. The import name is zanzibar.

Quickstart

from sqlmodel import SQLModel, Session, create_engine
from zanzibar import Store

SCHEMA = """
model
  schema 1.1
type user
type group
  relations
    define member: [user, group#member]
type doc
  relations
    define banned: [user]
    define viewer: [user, group#member] but not banned
"""

engine = create_engine("sqlite:///perms.db")
SQLModel.metadata.create_all(engine)   # creates the zanzibar_* tables

with Session(engine) as session:
    store = Store(session, "my-app", schema=SCHEMA)
    # add_tuple(user, relation, object), in OpenFGA's "type:name[#relation]" form
    store.add_tuple("user:alice", "member", "group:eng")
    store.add_tuple("user:bob", "member", "group:eng")
    store.add_tuple("group:eng#member", "viewer", "doc:d1")   # every member of eng
    print(store.check("user:alice", "viewer", "doc:d1"))      # True
    print(store.check("user:carol", "viewer", "doc:d1"))      # False

    store.add_tuple("user:bob", "banned", "doc:d1")
    print(store.check("user:bob", "viewer", "doc:d1"))        # False
    print(store.check("user:alice", "viewer", "doc:d1"))      # True

Each write commits and returns a freshness token. A store's schema is write-once: reopening with Store(session, "my-app") reads the stored one.

Documentation

The user documentation is at https://averykhoo.github.io/graph-reachability-zanzibar-index/:

Before a first deploy, read the guides to async mode and freshness tokens, runtime checks in production, pruning the change outbox, and the exceptions reference.

License

Apache-2.0. See LICENSE in the source repository.

Metadata

Release files for zanzibar-index 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zanzibar-index 0.1.2
File Size Uploaded Provenance Actions
zanzibar_index-0.1.2.tar.gz 339.2 kB With provenance Details for zanzibar_index-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zanzibar-index 0.1.2
File Interpreter ABI Platform Actions
zanzibar_index-0.1.2-py3-none-any.whl Python 3 none any Details for zanzibar_index-0.1.2-py3-none-any.whl

Total release size: 665.9 kB

Release files / zanzibar_index-0.1.2.tar.gz

Download URL zanzibar_index-0.1.2.tar.gz
Size 339.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4f148862654946ca8939055f1539ed797417788e730fa42358c63882523b7814
BLAKE2b-256 checksum
How to use checksums
a7f4bf5dba6511eff5bde9031c357840ee568983873e41f3e5838437367739de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Release files / zanzibar_index-0.1.2-py3-none-any.whl

Download URL zanzibar_index-0.1.2-py3-none-any.whl
Size 326.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee156ad22a87dcd1095a7ac749df51dca5e3fcfcee0b04158b66c639021ed8fa
BLAKE2b-256 checksum
How to use checksums
5ae38673a8325c61a7ebaba686b102f127bb81f9cfc03ac03bca1205ab2a4724
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Security for zanzibar-index 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for zanzibar_index-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page