Skip to content

Commit

Permalink
Make example more simple + add info about why to use getUserPermissio…
Browse files Browse the repository at this point in the history
…nsWithOPA
  • Loading branch information
gideonsmila committed Dec 23, 2024
1 parent 962ae13 commit 91c788d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions docs/how-to/enforce-permissions/user-permissions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,15 @@ UserPermissions permissions = permit.getUserPermissions(

## Get user permissions directly from opa

:::info Info
:::info Note
This feature is not supported when using FactDB and should not be used with FactDB enabled on the PDP
:::

:::info Info
When experiencing high load, it may be more efficient to call the OPA engine directly from the SDK.
Please note that to enable this, you will need to expose the OPA port (8181).
:::

```java
import io.permit.sdk.Permit;
import io.permit.sdk.PermitConfig;
Expand All @@ -179,16 +184,9 @@ Permit permit = new Permit(
new PermitConfig.Builder("[YOUR_API_KEY]").build()
);

Context context = new Context();
context.put("enable_abac_user_permissions", new Boolean(true));

UserPermissions permissions = permit.getUserPermissionsFromOPA(
new GetUserPermissionsQuery(
User.fromString("john@doe.com"), // user key
null, // tenants filter is not required for ABAC
Arrays.asList("document", "__tenant"), // resource types is always required for ABAC, __tenants is required to not ignore RBAC-based permissions
null, // resources not required
context,
User.fromString("john@doe.com")
)
);

Expand Down

0 comments on commit 91c788d

Please sign in to comment.