mirror of https://github.com/buster-so/buster.git
added security check on the post and put endponts.
This commit is contained in:
parent
d77830dc13
commit
cddd790761
|
@ -21,9 +21,12 @@ export async function createShortcutHandler(
|
|||
|
||||
// Check if user has permission to create workspace shortcuts
|
||||
if (data.sharedWithWorkspace) {
|
||||
// TODO: Check if user is admin/has permission to create workspace shortcuts
|
||||
// For now, we'll allow any authenticated user to create workspace shortcuts
|
||||
// This should be updated based on your permission system
|
||||
// Only workspace_admin or data_admin can create workspace shortcuts
|
||||
if (userOrg.role !== 'workspace_admin' && userOrg.role !== 'data_admin') {
|
||||
throw new HTTPException(403, {
|
||||
message: 'Only workspace admins and data admins can create workspace shortcuts',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Check for duplicate name
|
||||
|
|
|
@ -42,19 +42,21 @@ export async function updateShortcutHandler(
|
|||
}
|
||||
|
||||
// For personal shortcuts, only creator can update
|
||||
// For workspace shortcuts, check admin permission (TODO)
|
||||
if (!existingShortcut.sharedWithWorkspace && existingShortcut.createdBy !== user.id) {
|
||||
throw new HTTPException(403, {
|
||||
message: 'You can only update your own shortcuts',
|
||||
});
|
||||
}
|
||||
|
||||
// For workspace shortcuts, check admin permission
|
||||
if (existingShortcut.sharedWithWorkspace) {
|
||||
// TODO: Check if user is admin/has permission to update workspace shortcuts
|
||||
// For now, we'll allow the creator to update their workspace shortcuts
|
||||
if (existingShortcut.createdBy !== user.id) {
|
||||
// Only workspace_admin, data_admin, or the creator can update workspace shortcuts
|
||||
const isAdmin = userOrg.role === 'workspace_admin' || userOrg.role === 'data_admin';
|
||||
const isCreator = existingShortcut.createdBy === user.id;
|
||||
|
||||
if (!isAdmin && !isCreator) {
|
||||
throw new HTTPException(403, {
|
||||
message: 'Only administrators can update workspace shortcuts',
|
||||
message: 'Only workspace admins, data admins, or the shortcut creator can update workspace shortcuts',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue