Turn a Cerbos query plan into a database filter, so a list query returns only the records the current user is allowed to see.
You call Cerbos's PlanResources
API with a principal, a resource kind and an action. Cerbos answers with one of three plan kinds:
always allowed, always denied, or conditional with an expression tree. An adapter turns
that tree into the native filter for your ORM or store (a Prisma where, a SQL fragment, a Mongo
query, an Elasticsearch query, and so on) using a mapping you provide from Cerbos attribute paths
(request.resource.attr.status) to your fields.
| Store / ORM | Language | Install | Docs |
|---|---|---|---|
| Prisma | TypeScript | npm install @cerbos/orm-prisma @cerbos/core |
prisma |
| Drizzle ORM | TypeScript | npm install @cerbos/orm-drizzle @cerbos/core |
drizzle |
| Mongoose | TypeScript | npm install @cerbos/orm-mongoose @cerbos/core |
mongoose |
| Convex | TypeScript | npm install @cerbos/orm-convex @cerbos/core |
convex |
| LangChain.js / ChromaDB | TypeScript | npm install @cerbos/langchain-chromadb @cerbos/core |
langchain-chromadb |
| SQLAlchemy | Python | pip install cerbos-sqlalchemy |
sqlalchemy |
| Ent | Go | go get github.com/cerbos/query-plan-adapters/ent |
ent |
| pgx / PostgreSQL | Go | go get github.com/cerbos/query-plan-adapters/pgx |
pgx |
| JPA (Hibernate, Quarkus, Jakarta EE, Micronaut) | Java | Build from source (not yet on Maven Central) | jpa |
| Spring Data JPA | Java | Build from source (not yet on Maven Central) | spring-data |
| Elasticsearch | Java | Build from source (not yet on Maven Central) | elasticsearch-java |
| Exposed (alpha) | Kotlin | Build from source (not yet on Maven Central) | exposed |
| ActiveRecord | Ruby | Not released yet | activerecord |
| Sequel | Ruby | Not released yet | sequel |
| MongoDB driver / Mongoid | Ruby | Not released yet | mongodb-ruby |
| Entity Framework Core | C# / .NET | Not released yet (Cerbos.QueryPlan.EntityFrameworkCore on NuGet once tagged) |
efcore |
Each adapter's README starts with an install step and a quick-start snippet.
Warning
The ActiveRecord, Sequel and MongoDB Ruby adapters are work-in-progress prototypes. They are unreleased, have not been used in production, and their interfaces may change without deprecation. Do not rely on them to enforce access control in a live system yet.
- Ask Cerbos for a plan:
planResources({ principal, resource: { kind }, action }). - Pass the plan and your attribute mapping to the adapter.
- Branch on the result: return nothing for always denied, run the query unfiltered for always allowed, and apply the returned filter for conditional.
If a policy uses a shape the adapter cannot express in your store, the adapter throws rather than
return a filter that might over-grant. Each adapter's Conformance contract section lists what it
supports and what it refuses.
Every adapter is tested against two shared corpora in this repository:
-
conformance/: hostile policy shapes, written as cases, and seed rows. The plans andcheck()decisions of two pinned Cerbos PDP releases (the current one and the one before) are recorded per case. Each adapter translates every recorded plan, runs it against a real store, and must return exactly the rows the PDP allowed, or throw. -
demo/: one realistic domain. Each adapter's example app installs the packaged adapter and uses it with its ORM's real query methods. The Go adapters use a localreplacedirective, so their examples cover usage but not packaging.
Contributors: start with CLAUDE.md, conformance/README.md and CODING_STANDARDS.md.