Hi guys, we are trying out modelling an ABAC polic...
# permit-saas
m
Hi guys, we are trying out modelling an ABAC policy involving role attributes. However, that doesn't seem to work. When starting the PDP locally, it's also complaining a little bit about the attribute. ABAC policies with other user or tenant attributes work just fine. Am I missing something? Thanks for you help 🙏 🙂
a
Hi @Maxim Baldinger, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
* Based on the documentation, when working with ABAC policies in Permit.io, role attributes need to be referenced differently than regular user or tenant attributes. In ABAC conditions, you reference role assignments using
user.roles
with the
array_contains
operator (1) (2) . Here's how it works: For checking if a user has a specific role in your ABAC conditions:
Copy code
{
  "user.roles": {
    "array_contains": "AccountOwner"
  }
}
(2) (3) This is different from regular user attributes (like
user.university
or
user.is_full_time
) which are referenced directly (1) . Role information is stored as an array of role keys assigned to the user, not as a standard attribute (1) (2) . If you're trying to create conditions based on roles, you'll need to combine them with other user or resource attributes. For example:
Copy code
{
  "allOf": [
    {
      "user.roles": {
        "array_contains": "admin"
      }
    },
    {
      "user.time_based_groups": {
        "any_match": {
          "match": {
            "expires": {
              "greater-than-equals": {
                "ref": "user.current_time"
              }
            }
          }
        }
      }
    }
  ]
}
(2) To help debug your specific issue, could you share: 1. Which Workspace / Project / Env you are using 2. What calls you are performing (as SDK code or CURL) 3. Which PDP version you are running 4. The relevant logs from your PDP showing the attribute complaint This will help our engineers investigate the specific error you're encountering.
To learn more, see the sources I considered: [[1] Building Your First ABAC Policy](https://docs.permit.io/how-to/build-policies/abac/building-abac-policy) [[2] Time Based Role Example](https://docs.permit.io/how-to/build-policies/abac/time-based-role) [[3] Fintech / Banking Demo Application](https://docs.permit.io/modeling/mesa-verde)
Appreciate the feedback! Feel free to ask me again with additional guidance or context.
m
My question is about attributes I define on a role. Equivalent to how I'd do it with attributes defined on a tenant.
o
Role attributes are not available for the policy checks them selves, but only as filtersnfor some of the APIs as noted here https://docs.permit.io/api/examples/filter-role-associations/
You can still use the role itself as an attribute as part of the policy, and of course the user or tenant attributes
m
Thanks for the quick reply! 🙏
But I can choose attributes defined on roles in the ABAC policy editor (when creating a resource set). How does this then work? 🤔
o
I stand corrected, it was added as an EAP (early-access-program) feature; But it seems you can only use it on user-sets not resource-sets
Anyways as this feature isn’t very mature, I’m not sure I’d recommend using it
m
Ok, I missed it. Thanks for the clarification!