Hi everyone! I'm experiencing an issue with AB...
# general
p
Hi everyone! I'm experiencing an issue with ABAC where user sets and resource sets aren't working together as expected. I followed the exact setup from this official video tutorial (

https://youtu.be/QCsWlsjEE5A?si=75kGOPioK2Dps8g5▾

), but I'm running into permission denied issues. My Setup User Configuration • Test User:
test-user5@test.com
• Assigned Role: Manager • User Attributes: ◦ `location`: "USA" ◦ `department`: "Eng" Resource Configuration • Resource Type: Services • Resource Attributes: ◦ `cost`: numeric value ◦ `hasApproval`: boolean User Set Definition Engineer Managers in USA: { "allOf": [ { "allOf": [ { "user.location": { "equals": "USA" } }, { "user.department": { "equals": "Eng" } } ] } ] } Resource Sets Services Above $500: { "allOf": [ { "allOf": [ { "resource.hasApproval": { "equals": true } }, { "resource.cost": { "greater-than-equals": 500 } } ] } ] } Services Below $500: { "allOf": [ { "allOf": [ { "resource.cost": { "less-than": 500 } }, { "resource.hasApproval": { "equals": true } } ] } ] } Code Implementation const serviceCost = 400; const userEmail = "test-user5@test.com"; const userLocation = "USA"; const userDepartment = "Eng"; const serviceApproval = "true"; const checkPermission = async () => { setIsLoading(true); setError(null); try { const response = await fetch("/api/permit/check", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user: { key: userEmail, attributes: { location: userLocation, department: userDepartment, }, }, action: "subscribe", resource: { type: "services", attributes: { hasApproval: serviceApproval, cost: serviceCost, }, tenant: "default", }, }), }); if (!response.ok) { throw new Error(
HTTP error! status: ${response.status}
); } const result = await response.json(); setIsAllowedToSubscribe(result.permitted); } catch (err) { setError( err instanceof Error ? err.message : "Failed to check permission", ); } finally { setIsLoading(false); } }; ``` The Problem Main Issue: Permission is always denied when using user sets and resource sets together. The system only works when I assign permissions directly to the user's role and specific resources. Error Scenarios Scenario 1: "No User Roles" Error Sometimes I get this error even though the user IS assigned to a role: { "__data_use_debugger": true, "__input_use_debugger": true, "allow": false, "allowing_sources": [], "debug": { "rbac": { "allow": false, "code": "no_user_roles", "reason": "no roles assigned to user 'test-user5@test.com'", "support_link": "https://docs.permit.io/errors/no_user_roles" }, "request": { "action": "subscribe", "resource": { "attributes": { "cost": 400, "hasApproval": "true", "type": "services" }, "type": "services" }, "tenant": null, "user": { "attributes": { "department": "Eng", "location": "USA", "roles": [], "tenants": [] }, "key": "test-user5@test.com", "synced": false } } }, "debugger_activated": true } Workaround: Deleting and recreating the user with role assignment temporarily fixes this. Scenario 2: "No Permission" Error After recreating the user, I get this error indicating the system isn't matching the user to the user set: { "__data_use_debugger": true, "__input_use_debugger": null, "allow": false, "allowing_sources": [], "debug": { "rbac": { "allow": false, "code": "no_permission", "reason": "user 'test-user5@test.com' does not have any role that grants him the 'subscribe' permission on resources of type 'services'", "support_link": "https://docs.permit.io/errors/no_permission" }, "request": { "action": "subscribe", "resource": { "attributes": { "cost": 400, "hasApproval": "true", "type": "services" }, "type": "services" }, "tenant": null, "user": { "attributes": { "department": "Eng", "email": "test-user5@test.com", "key": "test-user5@test.com", "location": "USA", "roles": [ "Admin" ], "tenants": [ "default" ] }, "key": "test-user5@test.com", "synced": true } } }, "debugger_activated": true } Environment • PDP running on Docker • Direct role-to-resource permissions work fine • Issue only occurs with user set + resource set combinations Questions 1. Is there a known issue with user sets and resource sets working together? 2. Why does the system sometimes not recognize assigned roles? 3. Are there any configuration steps I might be missing for ABAC setup? 4. Is there a way to debug why the user isn't being matched to the user set? Any insights or suggestions would be greatly appreciated! Has anyone encountered similar issues with ABAC implementations? Thanks in advance! 🙏
a
Welcome! @Pouya Xo 😁 We’re glad to have you with us! Please ask in the #permit-saas channel — our AI agent (and the team!) will be happy to help.
o
Can you attach your workspace project and environment please 🙏🏻
p
Of course, My workspace is called xolab and my environment is production, and this is the email that is signed up contact@xolab.co
👀 1
a
Hey @Pouya Xo, we're investigating your problem. Will be back to you soon.
p
Hey thanks a lot, and please let me know if you needed more information!
o
Hey @Pouya Xo, The issue should be fixed now, restarting your PDP should make your call return allow-true Small modification you need to do is send the
serviceApproval
as boolean instead of string. As you can see in the response the policy engine gets it as string which makes your request result in false as
true != "true"
🙏 1
p
Just figured out the issue 2 minutes before your message - I was sending "true" as a string from the UI instead of a boolean true. That was causing the attribute matching to fail. Thank you all for the help! Hopefully this thread helps others who run into the same string vs boolean issue with ABAC attributes.