Hi, I am evaluating Permit for my client. I have o...
# permit-saas
ł
Hi, I am evaluating Permit for my client. I have one issue I can not figure out. I try to get UserPermissions from local PDP
Copy code
Context context = new Context();
context.put("enable_abac_user_permissions", Boolean.TRUE);
UserPermissions userPermissions = permit.getUserPermissions(new GetUserPermissionsQuery(User.fromString("123"), null,null, null, context));
I only get roles, but no resources or permissions. I have ABAC permission configured with resource and user attributes. Any clue what am I doing wrong ?
a
Hi @Łukasz Szydło, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
I see you're trying to get user permissions with ABAC support enabled. Based on the documentation, the
permit.getUserPermissions
function determines all user permissions for every registered resource across all tenants (1) . The correct Java syntax from the documentation is:
Copy code
import io.permit.sdk.Permit;
import io.permit.sdk.PermitConfig;
import io.permit.sdk.enforcement.*;
import java.util.Arrays;

Permit permit = new Permit(
    new PermitConfig.Builder("[YOUR_API_KEY]") .build()
) ;

UserPermissions permissions = permit.getUserPermissions(
    new GetUserPermissionsQuery(
        User.fromString("<mailto:john@doe.com|john@doe.com>")
    )
) ;
The function accepts a "User" as input and optionally a list of tenants to filter, and returns an object containing the details about the request for each assigned tenant, including the assigned tenant's attributes, and the allowed permissions . Since you're experiencing issues with ABAC permissions not showing resources or permissions, I need some additional information to help our engineers investigate: 1. Which Workspace / Project / Env are you using? 2. What calls are you performing (as SDK code or CURL) ? 3. Which PDP version are you running? 4. Can you share relevant logs from your PDP? This will help identify if there's a configuration issue with your ABAC setup or PDP version compatibility.
To learn more, see the sources I considered: [[1] Get user permissions](https://docs.permit.io/how-to/enforce-permissions/user-permissions)
r
Hey ! As you can see in the docs the AI Agent shared here -
Arrays.asList("document", "__tenant"), // resource types is always required for ABAC, __tenants is required to not ignore RBAC-based permissions
you’ll have to specify the resource type
ł
1. Thanks I have missed it. Let me try.
It is working for resources but I do not get results for resource sets
the check function is returning correct result
r
Let me take a look
o
Can you share • Your workspace, project, and environment • The request and response of the user permissions • The request and response of the check ( that is allowed by the ABAC rules ) • Is the resource you are checking synced as a resource instance in the permit environment with the relevant attributes?
ł
1. AdminPanelTest, default project, development env In the log file I only have urls without payloads. I have debug set to true in permit config. Should I enable something more to obtain requests ?
o
I mean what is the SDK / API call that you are doing - similarly to what you attached here, but after all the changes and for both the check and the user permissions
Copy code
Context context = new Context();
context.put("enable_abac_user_permissions", Boolean.TRUE);
UserPermissions userPermissions = permit.getUserPermissions(new GetUserPermissionsQuery(User.fromString("123"), null,null, null, context));
ł
Copy code
HashMap<String, Object> resourceAttributes = new HashMap<>();
        resourceAttributes.put("location", "NO");
//        System.out.println("UserKey: "+user.key);
        String action = "read";
        Resource resource = new Resource.Builder("Chargar").withAttributes(resourceAttributes).build();
        try {

            UserRead userRead = permit.api.users.get("123");

            boolean check = permit.check(User.fromString("123"), action, resource);
            System.out.println(check);
            Context context = new Context();
            context.put("enable_abac_user_permissions", Boolean.TRUE);
            UserPermissions userPermissions = permit.getUserPermissions(new GetUserPermissionsQuery(User.fromString("123"), null, List.of("Chargar", "NO_chargers", "__tenant"), null, context));
o
And regarding this question ?
• Is the resource you are checking synced as a resource instance in the permit environment with the relevant attributes?
I guess from the code that the resource instance is not synced into permit as you send the attributes on the fly to the permit.check call abac get user permissions requires you either to use synced resource instance or to send the resource instances that you want to “check on” The main reason is that the policy evaluation needs to know which actual resource instances can be checked on, as attributes are set on instances
ł
What I want to achieve is get information on which resource sets user has any permissions and list of attributes on this resource sets. What would be the proper way to do it ?
o
get user permissions is used to get the actual permissions the users has on concrete resource instances. If I understand you correctly, what you want to achieve is the matched usersets and given those matched usersets which resourcesets would give permissions to that user, right ?
ł
yes. I would like to know what attributes the resource needs to have to be accessible for particular user so I can filter resources when I am working with collections.
o
We currently do not have such a feature, this can be implemented using custom rego after configuring GitOps on your project