SpiceDB Schema Examples: Browse Real Authorization Schemas | AuthZed

Base Layer EP 03: Spencer Kimball on Governance Is the Real Blocker

Listen now

SpiceDB Schema Fundamentals

What goes into a SpiceDB schema

A SpiceDB schema declares the object types in your application, the relationships between them, and the permissions those relationships grant. It's how you describe your authorization model in a Zanzibar-style permission system. Four building blocks do most of the work:

Beyond those four, two operators show up everywhere worth recognizing: subject_type#relation lets a relation reference the result of another relation (subject sets and sub-groups), and the arrow operatorrelation->permission walks the graph ("the admins of the owning organization").

How to write your first schema

  1. Start with the resources. List the things in your product users act on: documents, repositories, projects, features. Each becomes a definition.
  2. Add the subject types. Almost every schema has definition user {}. If you have groups, teams, or organizations, define those too.
  3. Model the verbs. What can a user do? Read, write, delete, manage billing? Each verb is a permission on the resource.
  4. Map verbs to relations. For each permission, decide who has it. Direct readers? Members of the owning organization? Add the relations and compose them with the permission operators.
  5. Iterate in the playground. Write a few sample relationships and assertions, then refine. The SpiceDB Playground lets you experiment without standing up infrastructure.

Evolving a schema in production

Schemas are not write-once. As your product grows, your authorization model grows with it: new resource types, new roles, new caveats. SpiceDB is designed to make these changes safe.

Patterns worth knowing

Frequently asked questions

Where do these example schemas come from?

Link to:

How do I run one of these schemas locally?

Link to:

What's the difference between a relation and a permission?

Link to:

Can I mix attribute-based and relationship-based access control?

Link to:

How do I evolve a schema without breaking production?

Link to:

Where can I learn more about modeling permissions?

Link to:

Build authorization with confidence.

AuthZed is the team behind SpiceDB. Get production-grade fine-grained permissions for your application.