Skip to content

Commit

Permalink
fix: permission grants in open_item
Browse files Browse the repository at this point in the history
  • Loading branch information
KernelDeimos committed Nov 21, 2024
1 parent bfacfc2 commit 16257a7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/backend/src/routers/open_item.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,14 @@ module.exports = eggspress('/open_item', {
// Note: We always grant write permission here. If the user only
// has read permission this is still safe; user permissions
// are always checked during an app access.
const permission = `fs:${subject.uid}:write`;
const svc_permission = Context.get('services').get('permission');
await svc_permission.grant_user_app_permission(
actor, app.uid, permission, {}, { reason: 'open_item' }
);
const PERMS = action === 'write' ? ['read', 'write'] : ['read'];
for ( const perm of PERMS ) {
const permission = `fs:${subject.uid}:${perm}`;
const svc_permission = Context.get('services').get('permission');
await svc_permission.grant_user_app_permission(
actor, app.uid, permission, {}, { reason: 'open_item' }
);
}

// Generate user-app token
const svc_auth = Context.get('services').get('auth');
Expand Down

0 comments on commit 16257a7

Please sign in to comment.