mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 20:37:21 +00:00
- Introduced a new `createGuard` function to streamline the creation of Guard instances with permissions and roles. - Updated tests in `authorize.spec.ts` to reflect changes in permission checks, ensuring they now return undefined for denied permissions. - Added new `Permission` and `Policy` classes to improve type safety and flexibility in permission management. - Refactored middleware and controller files to utilize the updated permission structure, including context handling for permissions. - Created a new `SystemController.spec.ts` file to test the integration of the new permission system within the SystemController. - Removed legacy permission handling from core security files, consolidating permission logic within the new structure.
36 lines
876 B
TypeScript
36 lines
876 B
TypeScript
import { Permission } from "auth/authorize/Permission";
|
|
import { s } from "bknd/utils";
|
|
|
|
export const accessAdmin = new Permission("system.access.admin");
|
|
export const accessApi = new Permission("system.access.api");
|
|
export const configRead = new Permission(
|
|
"system.config.read",
|
|
{},
|
|
s.object({
|
|
module: s.string().optional(),
|
|
}),
|
|
);
|
|
export const configReadSecrets = new Permission(
|
|
"system.config.read.secrets",
|
|
{},
|
|
s.object({
|
|
module: s.string().optional(),
|
|
}),
|
|
);
|
|
export const configWrite = new Permission(
|
|
"system.config.write",
|
|
{},
|
|
s.object({
|
|
module: s.string().optional(),
|
|
}),
|
|
);
|
|
export const schemaRead = new Permission(
|
|
"system.schema.read",
|
|
{},
|
|
s.object({
|
|
module: s.string().optional(),
|
|
}),
|
|
);
|
|
export const build = new Permission("system.build");
|
|
export const mcp = new Permission("system.mcp");
|