Skip to content

Commit

Permalink
refactor(client): organize rbac, abac methods
Browse files Browse the repository at this point in the history
  • Loading branch information
david-r-cox committed Oct 11, 2024
1 parent d9d3a28 commit 9af1fe2
Show file tree
Hide file tree
Showing 23 changed files with 29 additions and 49 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 10 additions & 10 deletions client/src/abac/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export { checkAbacPolicy } from "./checkAbacPolicy";
export { createPolicy } from "./createPolicy";
export { deletePolicy } from "./deletePolicy";
export { evaluatePolicies } from "./evaluatePolicies";
export { getGroupAttribute } from "./getGroupAttribute";
export { getPolicy } from "./getPolicy";
export { getUserAttribute } from "./getUserAttribute";
export { setGroupAttribute } from "./setGroupAttribute";
export { setUserAttribute } from "./setUserAttribute";
export { updatePolicy } from "./updatePolicy";
export { checkAbacPolicy } from "./policy/checkAbacPolicy";
export { createPolicy } from "./policy/createPolicy";
export { deletePolicy } from "./policy/deletePolicy";
export { evaluatePolicies } from "./policy/evaluatePolicies";
export { getPolicy } from "./policy/getPolicy";
export { updatePolicy } from "./policy/updatePolicy";
export { getGroupAttribute } from "./attribute/getGroupAttribute";
export { getUserAttribute } from "./attribute/getUserAttribute";
export { setGroupAttribute } from "./attribute/setGroupAttribute";
export { setUserAttribute } from "./attribute/setUserAttribute";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 9 additions & 29 deletions client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,25 @@ import {
} from "./abac";
import { authenticate } from "./auth";
import {
Logger,
ApiKeyEntity,
ApiKeySummary,
ApiKeyMetadata,
ApiKeyId,
ApiKeyMetadata,
ApiKeySummary,
AuthResult,
Description,
GroupId,
Logger,
PermissionId,
PermissionName,
Policy,
PolicyId,
UserId,
RotateApiKeyResult,
GroupId,
RoleId,
RotateApiKeyResult,
UserId,
} from "./types";

/* TODO: Add:
1. ABAC (Attribute-Based Access Control):
- evaluatePolicies
- getGroupAttribute
2. API Keys:
- No missing functions
3. RBAC (Role-Based Access Control):
- createRole
- getParentRole
- getRolePermissions
- removeUserFromGroup
- removePermissionFromRole
4. Utils:
Expand Down Expand Up @@ -736,12 +726,7 @@ export class KeyHippo {
*/
async checkAbacPolicy(userId: UserId, policy: Policy): Promise<boolean> {
try {
return await checkAbacPolicy(
this.supabase,
userId,
policy,
this.logger,
);
return await checkAbacPolicy(this.supabase, userId, policy, this.logger);
} catch (error) {
this.logger.error(
`Error checking ABAC policy: ${error instanceof Error ? error.message : String(error)}`,
Expand All @@ -750,7 +735,6 @@ export class KeyHippo {
}
}


/**
* Creates a new ABAC (Attribute-Based Access Control) policy.
*
Expand Down Expand Up @@ -1407,11 +1391,7 @@ export class KeyHippo {
*/
async getPolicy(policyId: PolicyId): Promise<Policy> {
try {
return await getPolicy(
this.supabase,
policyId,
this.logger,
);
return await getPolicy(this.supabase, policyId, this.logger);
} catch (error) {
this.logger.error(
`Error retrieving policy: ${error instanceof Error ? error.message : String(error)}`,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 10 additions & 10 deletions client/src/rbac/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export * from "./addUserToGroup";
export * from "./removeUserFromGroup";
export * from "./assignPermissionToRole";
export * from "./createPermission";
export * from "./createRole";
export * from "./getParentRole";
export * from "./getRolePermissions";
export * from "./setParentRole";
export * from "./updateUserClaimsCache";
export * from "./userHasPermission";
export { addUserToGroup } from "./group/addUserToGroup";
export { removeUserFromGroup } from "./group/removeUserFromGroup";
export { assignPermissionToRole } from "./permission/assignPermissionToRole";
export { createPermission } from "./permission/createPermission";
export { userHasPermission } from "./permission/userHasPermission";
export { createRole } from "./role/createRole";
export { getParentRole } from "./role/getParentRole";
export { getRolePermissions } from "./role/getRolePermissions";
export { setParentRole } from "./role/setParentRole";
export { updateUserClaimsCache } from "./cache/updateUserClaimsCache";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 9af1fe2

Please sign in to comment.