Understanding the Role Hierarchy
ZITADEL has three levels of roles, each serving a different purpose:Instance Roles
Control access to the entire ZITADEL instance. Only relevant for self-hosted deployments where you manage the instance.IAM_OWNER: Full instance administration- Manage all organizations
- Configure instance-wide policies
Organization Roles
Control administrative access within a specific organization.ORG_OWNER
Complete control over the organization, its users, projects, and settings. Can manage all aspects of the organization.
ORG_USER_MANAGER
Can create, modify, and delete users within the organization. Cannot manage projects or organization settings.
ORG_PROJECT_PERMISSION_MANAGER
Can manage project grants and user grants (role assignments). Controls who has access to which projects.
ORG_AUDITOR
Read-only access to view organization data, users, projects, and audit logs. Cannot make changes.
Project Roles
Custom roles you define to control access to your applications. These are the roles your application uses for authorization. Examples:admin- Full access to the applicationeditor- Can create and modify contentviewer- Read-only accessreports:read- Can view reportsusers:write- Can manage users
How Role Assignment Works
Roles are assigned to users through user grants.The Relationship Model
- Who: A specific user
- Where: In which organization context
- What: Which project they can access
- How: With which project roles
Example
Alice works for Acme Corp (Organization A) and needs access to the Customer Portal (Project 1):admin and reports:read roles when accessing the Customer Portal.
Project Roles in Detail
Defining Roles
When you create a project, you define custom roles specific to that project:Role Naming Conventions
Simple Naming
Simple Naming
Use simple, descriptive names:
admineditorviewermanager
Resource-Based Naming
Resource-Based Naming
Use
resource:action format:users:readusers:writereports:readinvoices:admin
Hierarchical Naming
Hierarchical Naming
Use dot notation for hierarchies:
sales.managersales.repsupport.tier1support.tier2
Role Groups
Thegroup field helps organize roles in the UI:
Accessing Roles in Your Application
When a user authenticates, their roles are available in several places.In Tokens
If you enableprojectRoleAssertion on the project, roles appear in tokens:
ID Token:
Via Userinfo Endpoint
Via Introspection
Implementing Authorization
In Your Application
Once you have the user’s roles from the token, implement authorization logic:Middleware Example (Express.js)
Multi-Organization Role Assignments
A user can have different roles in the same project depending on which organization they’re acting in.Example Scenario
Bob is a consultant who works with multiple clients:- Via
bob@acme.com→ He has theadminrole - Via
bob@beta.com→ He has theviewerrole
Authorization Checks in ZITADEL
ZITADEL can enforce authorization at the authentication level.Authorization Required
Enable this on the project to ensure users have at least one role:- Users with role assignments can log in ✓
- Users without role assignments are denied ✗
Project Access Required
Ensure the user’s organization has access to the project:- Users from the owner organization can log in ✓
- Users from granted organizations can log in ✓
- Users from other organizations are denied ✗
Managing User Grants
Assigning Roles
Updating Role Assignments
Removing Role Assignments
Listing User Grants
See all of a user’s role assignments:Project Grants and Roles
When granting a project to another organization, you specify which roles they can assign:- Assign
viewerandeditorroles to their users ✓ - Cannot assign
adminrole ✗
Best Practices
Role Design Principles
Role Design Principles
- Principle of Least Privilege: Grant only the permissions users need
- Role Granularity: More specific roles are better than catch-all roles
- Avoid Role Explosion: Don’t create too many similar roles
- Document Roles: Clearly define what each role can do
- Review Regularly: Audit role assignments quarterly
Naming and Organization
Naming and Organization
- Use consistent naming across all projects
- Group related roles using the
groupfield - Use descriptive display names for the UI
- Keep role keys short and URL-safe
- Document role hierarchies if you use them
Authorization Implementation
Authorization Implementation
Multi-Tenant Considerations
Multi-Tenant Considerations
- Consider organization context when checking roles
- Use project grants to control cross-organization access
- Enable
projectAccessRequiredfor SaaS applications - Test authorization with users from different organizations
- Document which roles are available via project grants
Security
Security
- Enable
authorizationRequiredto prevent unauthorized access - Limit
ORG_OWNERrole assignments - Regularly audit role assignments and remove unused grants
- Use separate roles for admin vs user functionality
- Consider time-limited role assignments for temporary access
Common Authorization Patterns
Role-Based Access Control (RBAC)
The most common pattern - assign roles, check roles:Hierarchical Roles
Higher roles inherit lower role permissions:Resource-Based Roles
Roles tied to specific actions on resources:Organization-Scoped Authorization
Check roles in the context of a specific organization:Troubleshooting
Roles not appearing in tokens
Roles not appearing in tokens
Cause:
projectRoleAssertion is not enabledSolution:User can't log in despite having a user account
User can't log in despite having a user account
Cause:
authorizationRequired is enabled but user has no role assignmentsSolution: Assign at least one project role to the userUser from granted organization can't log in
User from granted organization can't log in
Cause: Role was removed from project grantSolution: Update the project grant to include the necessary roles
Wrong roles after switching organizations
Wrong roles after switching organizations
Cause: User has different role assignments in different organizationsSolution: This is expected behavior. Check the organization context in your authorization logic.
Related Concepts
Users
Users are assigned roles through user grants
Organizations
Organizations provide context for role assignments
Projects
Projects define the custom roles available for assignment