-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added new permission check: get user permissions
- Loading branch information
Showing
9 changed files
with
182 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/io/permit/sdk/enforcement/GetUserPermissionsQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package io.permit.sdk.enforcement; | ||
|
||
import io.permit.sdk.util.Context; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public final class GetUserPermissionsQuery { | ||
public final User user; | ||
public final List<String> tenants; | ||
public final List<String> resource_types; | ||
public final List<String> resources; | ||
public final Context context; | ||
|
||
/** | ||
* input to get user permissions api | ||
* | ||
* @param user the user we'd like to get a list of permissions for. | ||
* @param tenants filter only permissions granted on specific tenants. | ||
* @param resource_types filter permissions based on resource type. | ||
* @param resources filter permissions based on resource instance key. | ||
* @param context The context for the authorization check. | ||
*/ | ||
public GetUserPermissionsQuery(User user, List<String> tenants, List<String> resource_types, List<String> resources, Context context) { | ||
this.user = user; | ||
this.tenants = tenants; | ||
this.resource_types = resource_types; | ||
this.resources = resources; | ||
this.context = context; | ||
} | ||
|
||
public GetUserPermissionsQuery(User user, List<String> tenants, List<String> resource_types, List<String> resources) { | ||
this(user, tenants, resource_types, resources, new Context()); | ||
} | ||
|
||
public GetUserPermissionsQuery(User user, List<String> tenants, List<String> resource_types) { | ||
this(user, tenants, resource_types, null); | ||
} | ||
|
||
public GetUserPermissionsQuery(User user, List<String> tenants) { | ||
this(user, tenants, null); | ||
} | ||
|
||
public GetUserPermissionsQuery(User user) { | ||
this(user, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/java/io/permit/sdk/enforcement/ObjectPermissions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.permit.sdk.enforcement; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* The {@code ObjectPermissions} class represents a single object (tenant or resource instance) that the queried user can access. | ||
*/ | ||
public class ObjectPermissions { | ||
|
||
public final TenantDetails tenant; | ||
public final ResourceDetails resource; | ||
public final List<String> permissions; | ||
|
||
public ObjectPermissions(TenantDetails tenant, ResourceDetails resource, List<String> permissions) { | ||
this.tenant = tenant; | ||
this.resource = resource; | ||
this.permissions = permissions; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/io/permit/sdk/enforcement/ResourceDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.permit.sdk.enforcement; | ||
|
||
import io.permit.sdk.util.Context; | ||
|
||
import java.util.HashMap; | ||
|
||
/** | ||
* The {@code ResourceDetails} class represents a single resource instance information fetched from the PDP (key and attributes). | ||
*/ | ||
public final class ResourceDetails extends TenantDetails { | ||
public final String type; | ||
public ResourceDetails(String type, String key, HashMap<String, Object> attributes) { | ||
super(key, attributes); | ||
this.type = type; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.permit.sdk.enforcement; | ||
|
||
import java.util.HashMap; | ||
|
||
/** | ||
* The {@code UserPermissions} class represents all the objects a user can access. | ||
*/ | ||
final public class UserPermissions extends HashMap<String, ObjectPermissions> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters