OpenFGA — Fine-Grained Authorization at Scale
Model and evaluate complex permission policies with a relationship-based authorization system. Inspired by Google Zanzibar and backed by the CNCF.
What it is
OpenFGA is an open-source fine-grained authorization system backed by the CNCF. It is inspired by Google's Zanzibar paper and uses a relationship-based access control (ReBAC) model. You define authorization policies as relationships between users and objects using a simple DSL, and OpenFGA evaluates access checks in milliseconds.
OpenFGA targets backend developers and platform engineers who need authorization beyond simple RBAC. If your application has complex permission hierarchies -- document sharing, team-based access, organizational policies -- OpenFGA models these as relationship tuples.
How it saves time or tokens
Implementing fine-grained authorization from scratch requires building a policy engine, a tuple store, and evaluation logic. OpenFGA provides all three out of the box. The authorization model DSL lets you express complex policies in a few lines, and the API handles evaluation, caching, and consistency.
For AI applications, OpenFGA can control which users or agents can access specific resources, datasets, or model endpoints. This is particularly useful for multi-tenant AI platforms.
How to use
- Start OpenFGA with Docker:
docker pull openfga/openfga
docker run -p 8080:8080 -p 3000:3000 openfga/openfga run
- Create a store and define an authorization model:
curl -X POST http://localhost:8080/stores \
-H 'Content-Type: application/json' \
-d '{"name": "my-app"}'
- Write relationship tuples and check access via the REST API.
Example
# Authorization model DSL
model
schema 1.1
type user
type document
relations
define owner: [user]
define editor: [user] or owner
define viewer: [user] or editor
# Write a relationship tuple
curl -X POST http://localhost:8080/stores/{store_id}/write \
-H 'Content-Type: application/json' \
-d '{
"writes": {
"tuple_keys": [
{"user": "user:alice", "relation": "owner", "object": "document:report"}
]
}
}'
# Check access
curl -X POST http://localhost:8080/stores/{store_id}/check \
-H 'Content-Type: application/json' \
-d '{"tuple_key": {"user": "user:alice", "relation": "viewer", "object": "document:report"}}'
# Returns: {"allowed": true}
Related on TokRepo
- Security tools -- Browse other authorization and security tools
- API tools -- Explore API security and gateway solutions
Common pitfalls
- Authorization models must be written in OpenFGA's DSL, not arbitrary JSON. Syntax errors in the model definition produce cryptic error messages. Use the OpenFGA Playground to validate models before deploying.
- Relationship tuples accumulate over time. Without cleanup of stale tuples (e.g., when users leave an organization), the tuple store grows and check latency increases.
- OpenFGA evaluates authorization at request time. For pages showing many resources, batch the check calls using the list-objects API instead of making individual check calls per resource.
Frequently Asked Questions
RBAC assigns roles to users globally. OpenFGA uses relationship-based access control where permissions are defined as relationships between specific users and specific objects. This enables fine-grained policies like 'Alice can edit this document' rather than 'editors can edit all documents'.
OPA evaluates policies written in Rego against request data. OpenFGA evaluates relationship-based access checks against stored tuples. OPA is more general-purpose; OpenFGA is optimized for authorization with built-in tuple storage and relationship traversal.
Yes. OpenFGA is designed for production workloads with sub-millisecond check latency. It supports PostgreSQL and MySQL as backend stores for persistence. The CNCF backing ensures ongoing development and stability.
Yes. OpenFGA handles authorization only, not authentication. It works alongside any authentication provider (Auth0, Keycloak, Firebase Auth). After authenticating a user, you pass their identity to OpenFGA for authorization checks.
Yes. OpenFGA provides official SDKs for JavaScript, Python, Go, .NET, and Java. The SDKs wrap the REST API with typed interfaces for writing tuples, checking access, and managing authorization models.
Citations (3)
- OpenFGA GitHub— OpenFGA is a CNCF-backed fine-grained authorization system
- Google Zanzibar Paper— Inspired by Google Zanzibar paper
- OpenFGA Documentation— Relationship-based access control model
Related on TokRepo
Discussion
Related Assets
Conda — Cross-Platform Package and Environment Manager
Install, update, and manage packages and isolated environments for Python, R, C/C++, and hundreds of other languages from a single tool.
Sphinx — Python Documentation Generator
Generate professional documentation from reStructuredText and Markdown with cross-references, API autodoc, and multiple output formats.
Neutralinojs — Lightweight Cross-Platform Desktop Apps
Build desktop applications with HTML, CSS, and JavaScript using a tiny native runtime instead of bundling Chromium.