Model role-based access control in Permify — assign roles to users and attach permissions to those roles with a real-world SaaS example.
Role-Based Access Control (RBAC) is the right choice when access decisions depend on who a user is within an organization — admin, manager, member — rather than on specific resource relationships or request context. If your permission logic maps cleanly to a fixed set of named roles, RBAC is the simplest and most maintainable approach.In Permify, roles are modeled as relations on an entity. You assign users to those relations, then write actions (permissions) that reference them. No special role construct is required — the schema DSL handles it naturally.
This example models an organization with four roles — admin, manager, member, and agent — and two categories of resources: organization files and vendor files. Each resource category has its own set of permissions, and some roles have narrower access than others.
The organization entity declares four relations. Each relation maps directly to a role — any user can be assigned to one or more of them.Actions combine roles with boolean operators (or, not) to express nuanced rules:
action edit_files = admin or manager — only admins and managers can edit files.
action view_files = admin or manager or (member not agent) — admins, managers, and members who are not also agents can view files. Members who hold the agent role are excluded.
action delete_vendor_file = agent — only users with the agent role can delete vendor files.
Permify Schema supports and, or, not, and and not operators so you can express any combination of roles in a single action.
The following table summarizes which roles can perform each action in this schema.
Action
admin
manager
member
agent
view_files
✅
✅
✅
❌
edit_files
✅
✅
❌
❌
delete_file
✅
❌
❌
❌
view_vendor_files
✅
✅
❌
✅
edit_vendor_files
✅
❌
❌
✅
delete_vendor_file
❌
❌
❌
✅
A member who is also assigned the agent relation is denied view_files because of the member not agent expression. Both relations must be checked when evaluating that action.