mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-04 00:56:01 +00:00
Update permissions handling and enhance Guard functionality
- Bump `jsonv-ts` dependency to 0.8.6. - Refactor permission checks in the `Guard` class to improve context validation and error handling. - Update tests to reflect changes in permission handling, ensuring robust coverage for new scenarios. - Introduce new test cases for data permissions, enhancing overall test coverage and reliability.
This commit is contained in:
@@ -1,9 +1,51 @@
|
||||
import { Permission } from "auth/authorize/Permission";
|
||||
import { s } from "bknd/utils";
|
||||
|
||||
export const entityRead = new Permission("data.entity.read");
|
||||
export const entityCreate = new Permission("data.entity.create");
|
||||
export const entityUpdate = new Permission("data.entity.update");
|
||||
export const entityDelete = new Permission("data.entity.delete");
|
||||
export const entityRead = new Permission(
|
||||
"data.entity.read",
|
||||
{
|
||||
filterable: true,
|
||||
},
|
||||
s.object({
|
||||
entity: s.string(),
|
||||
id: s.anyOf([s.number(), s.string()]).optional(),
|
||||
}),
|
||||
);
|
||||
/**
|
||||
* Filter filters content given
|
||||
*/
|
||||
export const entityCreate = new Permission(
|
||||
"data.entity.create",
|
||||
{
|
||||
filterable: true,
|
||||
},
|
||||
s.object({
|
||||
entity: s.string(),
|
||||
}),
|
||||
);
|
||||
/**
|
||||
* Filter filters where clause
|
||||
*/
|
||||
export const entityUpdate = new Permission(
|
||||
"data.entity.update",
|
||||
{
|
||||
filterable: true,
|
||||
},
|
||||
s.object({
|
||||
entity: s.string(),
|
||||
id: s.anyOf([s.number(), s.string()]).optional(),
|
||||
}),
|
||||
);
|
||||
export const entityDelete = new Permission(
|
||||
"data.entity.delete",
|
||||
{
|
||||
filterable: true,
|
||||
},
|
||||
s.object({
|
||||
entity: s.string(),
|
||||
id: s.anyOf([s.number(), s.string()]).optional(),
|
||||
}),
|
||||
);
|
||||
export const databaseSync = new Permission("data.database.sync");
|
||||
export const rawQuery = new Permission("data.raw.query");
|
||||
export const rawMutate = new Permission("data.raw.mutate");
|
||||
|
||||
Reference in New Issue
Block a user