Skip to content

Commit

Permalink
Added Proxy Facts to Java SDK (#523)
Browse files Browse the repository at this point in the history
* Added Proxy Facts to Java SDK

* Added Java examples to PDP Proxy Facts
  • Loading branch information
danyi1212 authored Feb 26, 2025
1 parent efb9c87 commit 44708b5
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 40 deletions.
64 changes: 63 additions & 1 deletion docs/how-to/manage-data/local-facts-uploader.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: Send Critical Updates
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

When checking permissions right after creating or syncing a user, there may be a delay in data syncing to the PDP. To reduce this latency, we’ve implemented a mechanism that sends data updates directly to the PDP first, then distributes them through OPAL (including other PDPs if you operate in multi-PDP setup).
When checking permissions right after creating or syncing a user, there may be a delay in data syncing to the PDP. To reduce this latency, we've implemented a mechanism that sends data updates directly to the PDP first, then distributes them through OPAL (including other PDPs if you operate in multi-PDP setup).

The approach works by making calls directly to the PDP, which then forwards the facts to the connected OPAL Server. The OPAL Server will then distribute the facts to all the PDPs in the environment. The update has been added as a configuration option in the SDK which enables you to use the same favorite SDK to interact with Permit.io as you have previously without changing function calls. This approach will also ensure all other PDPs running in your environment receive those facts by forwarding the facts to the connected OPAL Server which then distributes the facts to all the PDPs in the environment.

Expand Down Expand Up @@ -84,6 +84,31 @@ func main() {
}
```

</TabItem>

<TabItem value="java" label="Java">

```java
import io.permit.sdk.Permit;
import io.permit.sdk.PermitConfig;

public class PermitExample {
public static void main(String[] args) {
// Initialize the SDK with your API key and PDP configuration
PermitConfig config = new PermitConfig.Builder("<your-api-key>")
// In production, you might need to change this URL to fit your deployment
// This is the address where you can find the PDP container
.withPdpAddress("http://localhost:7766")
// configure the SDK to upload facts via the PDP
.withProxyFactsViaPdp(true)
// Add here any more configurations that you usually use
.build();

Permit permit = new Permit(config);
}
}
```

</TabItem>
</Tabs>

Expand Down Expand Up @@ -202,6 +227,43 @@ func main() {

</TabItem>

<TabItem value="java" label="Java">

```java
import io.permit.sdk.Permit;
import io.permit.sdk.PermitConfig;
import io.permit.sdk.api.models.UserCreate;

public class PermitExample {
public static void main(String[] args) {
PermitConfig config = new PermitConfig.Builder("<your-api-key>")
.withPdpAddress("http://localhost:7766")
.withProxyFactsViaPdp(true)
// configure the default time to wait for the facts to be synced
.withFactsSyncTimeout(10)
.build();

Permit permit = new Permit(config);

// Create a new user and wait for sync
UserCreate user = new UserCreate.Builder("auth0|elon")
.withEmail("[email protected]")
.withFirstName("Elon")
.withLastName("Musk")
.withAttributes(Map.of(
"age", 50,
"favorite_color", "red"
))
.build();

// Using the default timeout configured in PermitConfig
permit.api.users.sync(user);
}
}
```

</TabItem>

</Tabs>

:::note Supported APIs
Expand Down
78 changes: 39 additions & 39 deletions docs/sdk/sdks-overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,45 @@ This page lists the feature parity of the different SDKs that we provide to use

🟀 - Not compatible (The feature cannot be implemented in the language due to language limitations)

| Feature ‡ | NodeJS | Go | .NET | Java | Python | Ruby | Terraform |
|--------------------------------|--------|----|------|------|--------|------|-----------|
| Check | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | 🟀 |
| Check All Tenants | βœ… | βœ… | πŸ”΄ | βœ… | πŸ”΄ | πŸ”΄ | 🟀 |
| Get User Permission | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | πŸ”΄ | 🟀 |
| Get User Permission (ABAC) | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | πŸ”΄ | 🟀 |
| Get User Tenant | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | πŸ”΄ | 🟀 |
| List Role Assignments from PDP | πŸ”΄ | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | 🟀 |
| Get Authorized Users | πŸ”΄ | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | βœ… | 🟀 |
| Get Authorized Users(ABAC) | πŸ”΄ | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | 🟀 |
| Check URL | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | πŸ”΄ | 🟀 |
| Sync User | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | 🟀 |
| Create User | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | 🟀 |
| Create User + Assign Roles | πŸ”΄ | πŸ”΄ | βœ… | βœ… | πŸ”΄ | πŸ”΄ | 🟀 |
| Users | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… |
| Resources | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… |
| Tenants | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… |
| Projects | βœ… | βœ… | πŸ”΄ | βœ… | βœ… | πŸ”΄ | πŸ”΄ |
| Environments | βœ… | βœ… | πŸ”΄ | βœ… | βœ… | πŸ”΄ | πŸ”΄ |
| Roles | βœ… | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | βœ… |
| Role Assignments | βœ… | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | πŸ”΄ |
| Condition Sets | βœ… | βœ… | πŸ”΄ | βœ… | βœ… | πŸ”΄ | βœ… |
| Condition Set Rules | βœ… | βœ… | πŸ”΄ | βœ… | βœ… | πŸ”΄ | βœ… |
| Relationship Tuples | βœ… | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | πŸ”΄ |
| Resource Relations | βœ… | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | βœ… |
| Role Derivations | πŸ”΄ | βœ… | πŸ”΄ | βœ… | πŸ”΄ | πŸ”΄ | βœ… |
| Resource Instances | βœ… | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | πŸ”΄ |
| Resource Roles | βœ… | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | πŸ”΄ |
| Resource Actions | βœ… | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | βœ… |
| Resource Action Groups | βœ… | βœ… | πŸ”΄ | βœ… | βœ… | πŸ”΄ | πŸ”΄ |
| Resource Attributes | βœ… | βœ… | πŸ”΄ | βœ… | βœ… | πŸ”΄ | βœ… |
| Bulk Check | βœ… | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | 🟀 |
| Elements Login | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | 🟀 |
| Bulk Users | βœ… | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | 🟀 |
| Bulk Relationship Tuples | βœ… | βœ… | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | 🟀 |
| Bulk Role Assignments | βœ… | βœ… | πŸ”΄ | βœ… | βœ… | πŸ”΄ | 🟀 |
| Bulk Tenants | πŸ”΄ | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | 🟀 |
| Bulk Resource Instances | πŸ”΄ | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | 🟀 |
| Proxy Facts via PDP | βœ… | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | 🟀 |
| Feature ‡ | NodeJS | Go | .NET | Java | Python | Ruby | Terraform |
|--------------------------------|---------|-----|-------|-------|----------|-------|------------|
| Check | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | 🟀 |
| Check All Tenants | βœ… | βœ… | πŸ”΄ | βœ… | πŸ”΄ | πŸ”΄ | 🟀 |
| Get User Permission | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | πŸ”΄ | 🟀 |
| Get User Permission (ABAC) | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | πŸ”΄ | 🟀 |
| Get User Tenant | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | πŸ”΄ | 🟀 |
| List Role Assignments from PDP | πŸ”΄ | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | 🟀 |
| Get Authorized Users | πŸ”΄ | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | βœ… | 🟀 |
| Get Authorized Users(ABAC) | πŸ”΄ | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | 🟀 |
| Check URL | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | πŸ”΄ | 🟀 |
| Sync User | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | 🟀 |
| Create User | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | 🟀 |
| Create User + Assign Roles | πŸ”΄ | πŸ”΄ | βœ… | βœ… | πŸ”΄ | πŸ”΄ | 🟀 |
| Users | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… |
| Resources | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… |
| Tenants | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… |
| Projects | βœ… | βœ… | πŸ”΄ | βœ… | βœ… | πŸ”΄ | πŸ”΄ |
| Environments | βœ… | βœ… | πŸ”΄ | βœ… | βœ… | πŸ”΄ | πŸ”΄ |
| Roles | βœ… | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | βœ… |
| Role Assignments | βœ… | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | πŸ”΄ |
| Condition Sets | βœ… | βœ… | πŸ”΄ | βœ… | βœ… | πŸ”΄ | βœ… |
| Condition Set Rules | βœ… | βœ… | πŸ”΄ | βœ… | βœ… | πŸ”΄ | βœ… |
| Relationship Tuples | βœ… | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | πŸ”΄ |
| Resource Relations | βœ… | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | βœ… |
| Role Derivations | πŸ”΄ | βœ… | πŸ”΄ | βœ… | πŸ”΄ | πŸ”΄ | βœ… |
| Resource Instances | βœ… | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | πŸ”΄ |
| Resource Roles | βœ… | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | πŸ”΄ |
| Resource Actions | βœ… | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | βœ… |
| Resource Action Groups | βœ… | βœ… | πŸ”΄ | βœ… | βœ… | πŸ”΄ | πŸ”΄ |
| Resource Attributes | βœ… | βœ… | πŸ”΄ | βœ… | βœ… | πŸ”΄ | βœ… |
| Bulk Check | βœ… | βœ… | βœ… | βœ… | βœ… | πŸ”΄ | 🟀 |
| Elements Login | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | 🟀 |
| Bulk Users | βœ… | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | 🟀 |
| Bulk Relationship Tuples | βœ… | βœ… | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | 🟀 |
| Bulk Role Assignments | βœ… | βœ… | πŸ”΄ | βœ… | βœ… | πŸ”΄ | 🟀 |
| Bulk Tenants | πŸ”΄ | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | 🟀 |
| Bulk Resource Instances | πŸ”΄ | πŸ”΄ | πŸ”΄ | πŸ”΄ | βœ… | πŸ”΄ | 🟀 |
| Proxy Facts via PDP | βœ… | βœ… | πŸ”΄ | βœ… | βœ… | πŸ”΄ | 🟀 |

:::info Terraform Provider
The Terraform provider is not a full SDK, it is a tool to manage Permit.io resources using Terraform. It is not possible to implement all the features of the Permit.io API in Terraform due to Terraform limitations and basic design principles.
Expand Down

0 comments on commit 44708b5

Please sign in to comment.