mirror of
https://github.com/HeyPuter/puter.git
synced 2025-02-02 23:28:39 +08:00
fix: add permission implicator for file modes
This commit is contained in:
parent
4aa72eaf15
commit
e63ab3a67f
@ -137,7 +137,7 @@ class FilesystemService extends AdvancedBase {
|
||||
matcher: permission => {
|
||||
return permission.startsWith('fs:');
|
||||
},
|
||||
checker: async (actor, permission) => {
|
||||
checker: async ({ actor, permission }) => {
|
||||
if ( !(actor.type instanceof UserActorType) ) {
|
||||
return undefined;
|
||||
}
|
||||
@ -162,6 +162,40 @@ class FilesystemService extends AdvancedBase {
|
||||
return {};
|
||||
}
|
||||
|
||||
return undefined;
|
||||
},
|
||||
}));
|
||||
svc_permission.register_implicator(PermissionImplicator.create({
|
||||
matcher: permission => {
|
||||
return permission.startsWith('fs:');
|
||||
},
|
||||
checker: async ({ actor, permission, recurse }) => {
|
||||
const parts = PermissionUtil.split(permission);
|
||||
if ( parts.length < 3 ) return undefined;
|
||||
|
||||
const specified_mode = parts[2];
|
||||
|
||||
const mode = {
|
||||
write: 'read',
|
||||
read: 'list',
|
||||
list: 'see',
|
||||
}[specified_mode];
|
||||
|
||||
if ( ! mode ) return undefined;
|
||||
|
||||
const perm = await recurse(actor,
|
||||
PermissionUtil.join(
|
||||
parts[0],
|
||||
parts[1],
|
||||
mode,
|
||||
...parts.slice(3),
|
||||
)
|
||||
)
|
||||
if ( perm ) {
|
||||
console.log('RETURNING IT!', perm);
|
||||
return perm;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
},
|
||||
}));
|
||||
|
Loading…
Reference in New Issue
Block a user