Hi Team, I've created a resource called DOMAIN_CSC...
# general
s
Hi Team, I've created a resource called DOMAIN_CSC with an action named access. This resource acts as a parent. There's another resource called CSE_RAG_AGENT, which is a child of DOMAIN_CSC. I want to enforce a condition such that access to CSE_RAG_AGENT should only be granted if DOMAIN_CSC has been marked with access. Essentially, the user's permission to access the agent should be dependent on the parent resource being accessible.
a
Hey @Shanmukh Adari, welcome 🙂 please ask questions in #permit-saas, meanwhile I’ll let our AI to answer @Ask Inkeep
a
Thanks for tagging me @Alon Boshi. I'll look through relevant sources and get back to you shortly.
To implement parent-child resource access control where access to CSE_RAG_AGENT depends on DOMAIN_CSC having access, you can use Permit.io's ReBAC (Relationship-Based Access Control) with role derivations (1) . Here's how to set this up: 1. Define the Parent-Child Relationship First, create a relation linking your child resource to its parent (2) :
Copy code
await permit.api.resource_relations.create(
    "CSE_RAG_AGENT",
    {
        "key": "parent",
        "name": "Parent",
        "subject_resource": "DOMAIN_CSC",
    }
)
2. Configure Role Derivation Role derivation allows users with permissions on the parent resource to automatically inherit permissions on child resources (1) . This means when a user has access to DOMAIN_CSC, they'll automatically get the derived permissions for CSE_RAG_AGENT instances that are children of that DOMAIN_CSC . The derivation works by: 1. Configuring a derivation between roles in your system 2. When a relationship tuple is created between resources, users with explicit grants to one resource implicitly gain permissions to related resources 3. Create the Relationship Instance When you create a CSE_RAG_AGENT instance, establish its relationship to the parent DOMAIN_CSC (2) :
Copy code
await permit.api.relationship_tuples.create({
    subject: "DOMAIN_CSC:specific_domain_id",
    relation: "parent", 
    object: "CSE_RAG_AGENT:specific_agent_id"
})
(3) This creates a relationship tuple indicating that the specific DOMAIN_CSC instance is the parent of the specific CSE_RAG_AGENT instance (1) . With this setup, users who have access permission on DOMAIN_CSC will automatically inherit the appropriate permissions for its child CSE_RAG_AGENT resources through the role derivation mechanism .
To learn more, see the sources I considered: [[1] What is ReBAC?](https://docs.permit.io/how-to/build-policies/rebac/overview) [[2] Modeling Google Drive Permissions with ReBAC](https://docs.permit.io/modeling/google-drive) [[3] Authentication and Authorization with Firebase](https://www.permit.io/blog/authentication-and-authorization-with-firebase)