-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(vaults): Introduce ACLType (#6515)
- Loading branch information
Showing
4 changed files
with
65 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { ModelId } from "../shared/model_id"; | ||
|
||
// Supported permissions | ||
export const SUPPORTED_PERMISSIONS = ["read", "write"] as const; | ||
|
||
export type SupportedPermissionType = (typeof SUPPORTED_PERMISSIONS)[number]; | ||
|
||
// Access Control Entry | ||
export type ACEType = { | ||
groupId: ModelId; | ||
permissions: SupportedPermissionType[]; | ||
}; | ||
|
||
// Access Control List | ||
export type ACLType = { | ||
aclEntries: Array<ACEType>; | ||
}; | ||
|
||
export function groupHasPermission( | ||
acl: ACLType, | ||
permission: SupportedPermissionType, | ||
groupId: ModelId | ||
): boolean { | ||
const entry = acl.aclEntries.find((ace) => ace.groupId === groupId); | ||
if (entry) { | ||
return entry.permissions.includes(permission); | ||
} | ||
return false; | ||
} |
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