InferaDB is a distributed, Google Zanzibar‑inspired authorization engine that replaces ad‑hoc database lookups and scattered logic with a unified, millisecond‑latency source of truth. With this SDK, you define permissions as policy‑as‑code and wire up a type‑safe client in just a few lines.
- Rust‑Native & Async: Fully integrated with the ecosystem (Tokio, Tracing) so you don't have to adapt generic policy engines to your runtime.
- Compile‑Time Safety: Catch permission model mistakes in your build pipeline and tests, preventing surprises in production.
- Standards‑Based & Audit‑Ready: Built on AuthZen with automatic multi‑tenant isolation and cryptographically verifiable audit trails out of the box.
Quick Start
-
Sign up for an account at InferaDB and create a new organization and vault.
-
Run the following Cargo command in your project directory:
cargo add inferadb -
In your project, create and configure a client instance:
use *; async
In Action
"Can this user do this?"
The most common question in any app. One line:
if vault.check.await?
"Who can access this?"
Building a share dialog or audit view? List everyone with access:
let viewers = vault.subjects
.with_permission
.on_resource
.collect
.await?;
// ["user:alice", "user:bob", "team:engineering"]
"What can this user see?"
Filtering a dashboard or search results by what the user can actually access:
let docs = vault.resources
.accessible_by
.with_permission
.of_type
.collect
.await?;
"Grant access to a team"
When Alice shares a folder with her team, everyone on that team gets access:
vault.relationships
.write
.await?;
"Inherit permissions from a parent"
Documents inside a folder should inherit the folder's permissions:
vault.relationships
.write
.await?;
// Now anyone who can view the folder can view the document
"Check multiple permissions at once"
Rendering a UI with edit, delete, and share buttons? Check them all in one round-trip:
let = vault.batch_check.await? else ;
Usage
Authorization API
let vault = client.organization.vault;
Permission Checks
let allowed = vault.check.await?;
Relationships
vault.relationships
.write
.await?;
Lookups
let docs = vault.resources
.accessible_by
.with_permission
.collect
.await?;
See the Authorization API Guide for ABAC context, batch checks, explain, simulate, watch, and more.
Management API
let org = client.organization;
Vaults
let vault = org.vaults
.create
.await?;
Schemas
vault.schemas.push.await?;
Members & Teams
org.members
.invite
.await?;
org.teams
.create
.await?;
Audit Logs
let events = org.audit.list.collect.await?;
See the Management API Guide for organizations, API clients, schema versioning, and more.
Local Development
Deploy a local instance of InferaDB, then configure your client to connect to it.
let client = builder
.url
.insecure // Disables TLS verification for local development
.credentials
.build
.await?;
Testing
Use MockClient for unit tests:
use ;
async
See the Testing Guide for InMemoryClient (full policy evaluation) and integration testing patterns.
Documentation
- API Reference - Full rustdoc documentation
Guides
| Topic | Description |
|---|---|
| Installation | Feature flags, optimized builds, TLS, MSRV |
| Authentication | Client credentials, bearer tokens, key management |
| Authorization API | Permission checks, relationships, lookups, watch |
| Integration Patterns | Axum, Actix-web, GraphQL, gRPC middleware |
| Error Handling | Error types, retries, graceful degradation |
| Testing | MockClient, InMemoryClient, TestVault |
| Schema Design | ReBAC patterns, role hierarchy, anti-patterns |
| Production Checklist | Deployment readiness |
| Troubleshooting | Common issues and solutions |
See docs/README.md for the complete documentation index.
Examples
Contributing
See CONTRIBUTING.md for development setup and guidelines.
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.