Skip to content

Commit

Permalink
change name for new get user permissions using opa
Browse files Browse the repository at this point in the history
  • Loading branch information
gideonsmila committed Dec 22, 2024
1 parent 2c315f3 commit a66bf1b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
26 changes: 17 additions & 9 deletions src/main/java/io/permit/sdk/Permit.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
package io.permit.sdk;

import java.io.IOException;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import io.permit.sdk.api.ApiClient;
import io.permit.sdk.api.ElementsApi;
import io.permit.sdk.api.PermitApiError;
import io.permit.sdk.enforcement.*;
import io.permit.sdk.enforcement.CheckQuery;
import io.permit.sdk.enforcement.Enforcer;
import io.permit.sdk.enforcement.GetUserPermissionsQuery;
import io.permit.sdk.enforcement.IEnforcerApi;
import io.permit.sdk.enforcement.Resource;
import io.permit.sdk.enforcement.TenantDetails;
import io.permit.sdk.enforcement.User;
import io.permit.sdk.enforcement.UserPermissions;
import io.permit.sdk.util.Context;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.List;

/**
* The {@code Permit} class represents the main entry point for interacting with the Permit.io SDK.
*
Expand Down Expand Up @@ -160,8 +168,8 @@ public UserPermissions getUserPermissions(GetUserPermissionsQuery input) throws
}

@Override
public UserPermissions getUserPermissionsWithOPA(GetUserPermissionsQuery input) throws IOException, PermitApiError {
return this.enforcer.getUserPermissionsWithOPA(input);
public UserPermissions getUserPermissionsFromOPA(GetUserPermissionsQuery input) throws IOException, PermitApiError {
return this.enforcer.getUserPermissionsFromOPA(input);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/permit/sdk/enforcement/Enforcer.java
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ public UserPermissions getUserPermissions(GetUserPermissionsQuery input) throws


@Override
public UserPermissions getUserPermissionsWithOPA(GetUserPermissionsQuery input) throws IOException, PermitApiError {
public UserPermissions getUserPermissionsFromOPA(GetUserPermissionsQuery input) throws IOException, PermitApiError {
// request body
Gson gson = new Gson();

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/io/permit/sdk/enforcement/IEnforcerApi.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.permit.sdk.enforcement;

import io.permit.sdk.api.PermitApiError;
import io.permit.sdk.util.Context;

import java.io.IOException;
import java.util.List;

import io.permit.sdk.api.PermitApiError;
import io.permit.sdk.util.Context;

public interface IEnforcerApi {
/**
* Checks if a `user` is authorized to perform an `action` on a `resource` within the specified context.
Expand Down Expand Up @@ -120,7 +120,7 @@ public interface IEnforcerApi {
* @throws PermitApiError if an error occurs while sending the authorization request to the PDP.
* @throws IOException if could not read the content of the returned http response.
*/
UserPermissions getUserPermissionsWithOPA(GetUserPermissionsQuery input) throws IOException, PermitApiError;
UserPermissions getUserPermissionsFromOPA(GetUserPermissionsQuery input) throws IOException, PermitApiError;

/**
* list all the tenants the user is associated with.
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/permit/sdk/e2e/RbacE2ETest.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ void testPermissionCheckRBAC() {
)
);

UserPermissions permissions_2 = permitOpa.getUserPermissionsWithOPA(
UserPermissions permissions_2 = permitOpa.getUserPermissionsFromOPA(
new GetUserPermissionsQuery(
User.fromString("auth0|elon")
)
Expand Down

0 comments on commit a66bf1b

Please sign in to comment.