diff --git a/docs/how-to/enforce-permissions/user-permissions.mdx b/docs/how-to/enforce-permissions/user-permissions.mdx index dea38f6c..9cfe8bb8 100644 --- a/docs/how-to/enforce-permissions/user-permissions.mdx +++ b/docs/how-to/enforce-permissions/user-permissions.mdx @@ -160,7 +160,38 @@ UserPermissions permissions = permit.getUserPermissions( ); ``` - +## Get user permissions directly from opa + +:::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; +import io.permit.sdk.enforcement.*; +import io.permit.sdk.util.Context; +import java.util.Arrays; + + +Permit permit = new Permit( + new PermitConfig.Builder("[YOUR_API_KEY]").build() +); + +UserPermissions permissions = permit.getUserPermissionsFromOPA( + new GetUserPermissionsQuery( + User.fromString("john@doe.com") + ) +); + +``` + +