Utham Prabhu
12/03/2025, 6:52 AMview, create, edit, and audit. We don’t want to map all 300+ API endpoints individually inside Permit. Instead, we want Permit to manage only feature-level permissions, and then our Django backend will map API routes to those permissions internally.
We also want to dynamically generate the sidebar based on the permissions Permit returns, so that each user only sees the modules they are allowed to access.
One thing we need guidance on: How do we best structure resources and resource sets in Permit so that we can group permissions cleanly (ex: Leaves-related permissions → Leaves sidebar items, Projects → Project sidebar items) and also keep a clean mapping between features and the many API endpoints behind them? Basically, Permit will be the single source of truth for “feature permissions,” and Django will handle API-level mapping internally — but we want to know the neatest way to aggregate and organize these resources inside Permit so that the structure scales well.Ask Inkeep
12/03/2025, 6:52 AMAsk Inkeep
12/03/2025, 6:53 AM# Example from Django integration
action = 'create'
resource = 'Post'
permitted = await permit.check(check.user, action, resource)
(2)
For your case, you'd have resources like:
• Leaves with actions: view, create, edit, audit
• Projects with actions: view, create, edit, audit
• Attendance with actions: view, create, edit, audit
• WRM with actions: view, create, edit, audit
Dynamic Sidebar Generation
You can use bulk permission checks to efficiently determine which modules a user can access. (3) The documentation shows this pattern:
await permit.loadLocalStateBulk([
{ action: "view", resource: "Topics_for_you", {
country: user.publicMetadata.country,
channel: user.publicMetadata.channel,
}},
// ... more checks
]) ;
For your sidebar, adapt this to check view permissions across all modules:
// Conceptual example based on the pattern
await permit.loadLocalStateBulk([
{ action: "view", resource: "Leaves" },
{ action: "view", resource: "Projects" },
{ action: "view", resource: "Attendance" },
{ action: "view", resource: "WRM" }
]) ;
Then conditionally render sidebar items based on these permissions.
Resource Sets for Grouping
If you need more granular control within modules, Resource Sets can help segment resources based on attributes. (4) For example:
{
"allOf": [
{
"resource.module": {
"equals": "Leaves"
}
}
]
}
(5)
This allows you to create condition-based policies while maintaining your clean feature-level structure.
Django Integration Pattern
In your Django backend, implement a middleware or decorator that maps API endpoints to Permit permissions: (2)
# Based on Django integration example
async def your_api_endpoint(request) :
action = 'create' # Map from your internal logic
resource = 'Leaves' # Map from your module
permitted = await permit.check(user_id, action, resource)
if permitted:
# Process the request
return JsonResponse({"message": "User is permitted"})
else:
return JsonResponse({"message": "User is not permitted"}, status=403)
This keeps Permit as your single source of truth for feature permissions while Django handles the endpoint-to-permission mapping internally.
Scaling Considerations
• Keep resources at the feature/module level (not individual endpoints) (1)
• Use roles to group common permission sets
• Consider using tenants if you have multi-organization requirements
• Leverage Resource Sets only when you need attribute-based segmentation within modules (4)
This structure scales well because you're managing permissions at the logical feature level rather than the implementation level (300+ endpoints) , while still maintaining fine-grained control through your Django backend.Ask Inkeep
12/03/2025, 6:53 AMOr Weis
12/03/2025, 7:09 AMAsk Inkeep
12/03/2025, 7:09 AMAsk Inkeep
12/03/2025, 7:09 AMA user assigned the role of an Owner on a folder will also get the Owner role on every file within that folderApplied to your use case: A user with
viewer role on the Leaves module automatically inherits viewer permissions on all Leaves-related sidebar items and sub-features.
Resource Roles Configuration
Instead of flat permissions, you'd define resource-specific roles :
• Leaves#viewer - can view all Leaves features
• Leaves#editor - can create/edit in Leaves module
• Leaves#auditor - can audit Leaves operations
• Projects#viewer, Projects#editor, etc.
Resource roles are formatted as Resource#Role , making them contextual to specific modules rather than global.
Implementation Structure
Based on the Mesa Verde banking example (2) , you'd configure:
resource "permitio_role" "Leaves_Viewer" {
key = "viewer"
name = "Viewer"
resource = permitio_resource.Leaves.key
permissions = ["view"]
depends_on = [permitio_resource.Leaves]
}
Dynamic Sidebar with getUserPermissions
The getUserPermissions function retrieves all user permissions across resources (3) :
await permit.getUserPermissions(user) ;
This returns all permissions for the user, which you can parse to dynamically build the sidebar showing only accessible modules.
Role Derivation for Feature Inheritance
Configure role derivations so module-level permissions cascade to features (4) :
• If a user has Leaves#editor role, they automatically get editor permissions on all Leaves sub-resources
• This eliminates managing individual feature permissions while maintaining granular control
The derivation creates implicit permission grants without explicit role assignments to each instance (1) .
Groups for Team Management
Use Groups to manage team-based access (5) :
1. Create groups like HR_Team or Finance_Team
2. Assign groups to modules with specific roles
3. Users in groups automatically inherit the module permissions
When you add users to a group, they automatically receive permissions assigned to that group .
Benefits of ReBAC Approach
1. *Hierarchical permission inheritance* - Module permissions flow to features automatically (1)
2. *Reverse queries* - Easily determine who has access to what using authorized_users (3)
3. *Clean getUserPermissions* - Single call retrieves all module access for sidebar generation
4. *Scalability* - Add new modules/features without permission explosion (4)
This ReBAC structure maintains Permit as your single source of truth for feature-level permissions while Django handles the API endpoint mapping, with the added benefit of natural hierarchical permission flow.Ask Inkeep
12/03/2025, 7:10 AMUtham Prabhu
12/03/2025, 7:33 AMOr Weis
12/03/2025, 7:55 AMAsk Inkeep
12/03/2025, 7:55 AMAsk Inkeep
12/03/2025, 7:56 AMawait permit.api.resource_relations.create(
"hr_screen",
{
"key": "parent",
"name": "Parent",
"subject_resource": "hr_module"
}
)
Configuring Role Derivations
Set up role derivation so that module-level roles cascade to all child resources (3) :
await permit.api.resource_roles.update(
"hr_screen",
"editor",
{
"granted_to": {
"users_with_role": [
{
"linked_by_relation": "parent",
"on_resource": "hr_module",
"role": "editor"
}
]
}
}
)
This means when Bob gets hr_module#editor, he automatically receives hr_screen#editor on all HR screens where the module is the parent (1) .
Multi-Tenant Implementation
For each tenant (Organization A, B, etc.) , create relationship tuples linking resources (3) :
await permit.api.relationship_tuples.create(
{
"subject": "hr_module:org_a",
"relation": "parent",
"object": "leave_management:org_a"
}
)
Practical Example Flow
1. Admin creates "HR" role in Organization A
2. Admin selects resources: Leave Management, Employee Records, Payroll
3. System creates relationships: hr_module:org_a → parent → leave_management:org_a (1)
4. Bob is assigned hr_module:org_a#editor
5. Bob automatically gets editor permissions on all child resources through role derivation
The ReBAC policy for this would be: "A user assigned the role HR_Module#Editor will also be assigned the Screen#Editor when the HR_Module instance is the Parent of a Screen instance" (4) .
Dynamic Sidebar Generation
Use the derived permissions to build navigation - users only see modules/screens they have access to through the relationship graph (2) .
Further Reading on ReBAC
• *What is ReBAC? * (1) - Core concepts of relationship-based access control
• *Building ReBAC Policies * (2) - Step-by-step guide for implementing ReBAC
• *Google Drive Example * (3) - Complete ReBAC implementation showing folder-file hierarchies
• *What is Relationship-Based Access Control (ReBAC) ? * (4) - Detailed blog explaining ReBAC benefits and use cases
ReBAC's graph-based approach perfectly fits your need to group resources and manage multi-tenant permissions where one role assignment cascades through related resources (1) .Ask Inkeep
12/03/2025, 7:56 AM