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.3

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.3
File Size Uploaded Provenance Actions
zanzibar_index-0.1.3.tar.gz 347.0 kB With provenance Details for zanzibar_index-0.1.3.tar.gz

Built distribution (wheel)

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

Total release size: 680.4 kB

Release files / zanzibar_index-0.1.3.tar.gz

Download URL zanzibar_index-0.1.3.tar.gz
Size 347.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f3aff7fb90f25e4910e4833d62e6706f4e6a68d7cb3439cf278e5271f42896f6
BLAKE2b-256 checksum
How to use checksums
a8ab56d6034fefe8429e7865648a30da981ad9b032de312161a9928e1baee2ea
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 Nov 25, 2026.

Transparency log

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

Download URL zanzibar_index-0.1.3-py3-none-any.whl
Size 333.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c5ae4ad1aa2131098739454f4c6702ca3d6c229149ec1a3b211950d2ed1b1fae
BLAKE2b-256 checksum
How to use checksums
856a5f3fc43de5ea6a9120668869a2763d05d543c04f0e716a0f5e3c8d6c6b54
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 Nov 25, 2026.

Transparency log

Security for zanzibar-index 0.1.3

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.3.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 Nov 25, 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