Permify Schema
Permify has its own schema language (DSL) for modeling authorization logic. With it you can:- Define entities that represent your application’s resources and actors.
- Define relations between entities (e.g. a user is an admin of an organization).
- Define permissions (also called actions) that express what a subject can do on a resource.
- Use set-algebraic operators —
and,or,not— to compose complex access rules. - Add attributes and rules to support attribute-based access control (ABAC).
.perm).
Developing a schema
The following steps walk through building a schema from scratch using a simplified GitHub authorization model, where organizations, teams, and users have different levels of access to repositories.Define entities
Entities are the core objects in your permission system — think of them as your database tables. Use the Each entity can contain relations, permissions, and attributes. The
entity keyword to declare them.user entity is mandatory in Permify — it acts as the reference point for all subjects.Define relations
Relations describe how entities relate to each other. They form the backbone of Permify’s evaluation engine.Relation attributes:The This means a maintainer can be either a
- name — letters and underscores only, max 64 characters.
- type — the entity type this relation references (must exist in the schema).
Roles and user types
Define roles directly on the entity that owns them:Parent-child relationships
Model hierarchies using aparent relation:parent relation links the team to its owning organization, establishing a parent-child hierarchy.Ownership
Represent resource ownership with a dedicated relation:Multiple relation types
Themaintainer relation above accepts two types:user directly, or any member of a team. The # character is used to reference a relation on another entity — this is called feature locking, and it locks the relation type to the specified sub-relation.Feature locking lets you define sets of users. For example:This allows individual users and entire organization member sets to be assigned as viewers:
document:1#viewer@user:U1document:1#viewer@organization:O1#member
viewer relation to all members of organization O1.Define permissions
Permissions (also written as The Users tagged with The
action) define what subjects are allowed to do on an entity.The basic form of an authorization check is: Can user U perform action X on resource Y?The keywords action and permission are interchangeable.Union (or)
Useor to grant access if the subject satisfies any of the conditions:Intersection (and)
Useand to require the subject to satisfy all conditions:delete action requires the user to be an organization admin and also be an owner, maintainer, or member.When using
and with a traversal like org.member and org.admin, Permify evaluates each side across all reachable organizations and then intersects the results. If you need both conditions to be satisfied on the same organization, define the intersection on the organization entity and reference it from the child:Exclusion (not)
Usenot to exclude a set of subjects:restricted = true are excluded from the comment and like actions.Permission union (inherited permissions)
Permissions can reference other permissions, enabling inheritance:delete action inherits everything from edit and additionally grants access to organization admins.Attribute-based permissions (ABAC)
Permify extends ReBAC with attribute support, allowing you to write conditions based on properties of entities.Defining attributes
Attributes associate typed values with entities:Defining rules
Rules are condition functions that accept parameters and returntrue or false. They use Common Expression Language (CEL) syntax:
view is granted to admins or to any user whose IP address falls within the organization’s allowed IP range.
Modeling guides
Explore guides for common authorization patterns:RBAC Guide
Role-based access control patterns including global, resource-specific, and custom roles.
ReBAC Guide
Relationship-based patterns including groups, hierarchies, and recursive structures.
ABAC Guide
Attribute-based patterns including boolean flags, string conditions, and numerical rules.