Hi Team Consider there are 2 types of roles. One ...
# permit-saas
s
Hi Team Consider there are 2 types of roles. One is on a global level (super_admin) role and the other is at a instance level (project_admin, project_coordinator) role. super_admin can access all resources of the app, whereas project_admin can only access all resources of the project (authorised). Now, One user can be assigned with multiple projects with multiple roles. There is a project listing page common for all where we list all the projects a user is assigned with. super_admin gets all the projects (RBAC), project_admin gets only the authorised projects (ReBAC - gets project instances). Let's say the user is assigned with a few roles for specific instances (example project_id: 1 --> project_admin, project_id: 2 --> project_coordinator). How would i get all the project instances authorised to a user? project_admin or project_coordinator roles are for a specific project. Do we need to create another role (RBAC) which basically creates access to projects resource as a whole to enable listing of all kinds of projects authorised for a user or handle programmatically in code?
👀 1
p
Hey, thanks for reaching out ! It seems our team is a little busy right now, a human will be with you within the next hour or so. In the meantime, can I help you ?
a
Hi @Shaik Mohammad Abdullah, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
Based on the sources, you don't need to create another RBAC role for listing projects. Permit.io provides methods to query resource instances that users have access to through their resource-level roles. For your use case with project-level roles (project_admin, project_coordinator) , you can use resource instance roles in ReBAC (1) . When you assign a user to a specific project with a role, you're creating a resource instance role assignment (2) :
Copy code
await permit.api.roleAssignments.assign({
  role: "project_admin",
  tenant: "default",
  resource_instance: `Project:${project.id}`,
  user: "<mailto:user@example.com|user@example.com>",
}) ;
To get all project instances a user is authorized for, you can use the
getUserPermissions
function (3) :
Copy code
const transactionInstances = await permit.getUserPermissions(key, [tenant], [], ["Transaction"]) ;
For your projects, this would look like: • Query all Project resource instances the user has any role on • The function will return instances where the user has project_admin or project_coordinator roles • Your super_admin with tenant-level RBAC role would still have access to all projects through standard RBAC checks This approach combines RBAC (for super_admin) and ReBAC (for project-specific roles) without requiring additional roles (4) . The ReBAC model handles the project-level permissions through resource roles and relationships (1) , while RBAC handles the global super_admin access (4) .
To learn more, see the sources I considered: [[1] What is ReBAC?](https://docs.permit.io/how-to/build-policies/rebac/overview) [[2] Sync Data into your App](https://docs.permit.io/overview/sync-applications-data) [[3] Fintech / Banking Demo Application](https://docs.permit.io/modeling/mesa-verde) [[4] Role-Based Access Control (RBAC) VS. Relationship-Based Access Control (ReBAC)](https://www.permit.io/blog/rbac-vs-rebac)