Skip to content

Commit 04b17f2

Browse files
authored
fix(versionsource): "delegate" permission check to api (#179)
1 parent 5182cd5 commit 04b17f2

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/utils/auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ export async function getAclCtx(env, org, users, key, api) {
297297
// Expose the action trace or not?
298298
actionTrace = users.every((u) => aclTrace.includes(u.email)) ? actionTrace : undefined;
299299

300-
if (k === 'CONFIG') {
300+
if (k === 'CONFIG' || api === 'versionsource') {
301301
actionSet.add('read');
302302
}
303303

test/utils/auth.test.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,20 @@ describe('DA auth', () => {
302302
const users = [{email: "blah@foo.org"}];
303303
const aclCtx = await getAclCtx(env2, 'test', users, '/', 'config');
304304
assert(aclCtx.actionSet.has('read'));
305-
})
305+
});
306+
307+
it('test versionsource api always has read permission', async () => {
308+
const users = [{email: "blah@foo.org"}];
309+
const aclCtx = await getAclCtx(env2, 'test', users, '/', 'versionsource');
310+
assert(aclCtx.actionSet.has('read'));
311+
});
312+
313+
it('test versionsource api grants read permission even without explicit permissions', async () => {
314+
const users = [{email: "unauthorized@example.com"}];
315+
const aclCtx = await getAclCtx(env2, 'test', users, '/restricted', 'versionsource');
316+
assert(aclCtx.actionSet.has('read'));
317+
assert(!aclCtx.actionSet.has('write'));
318+
});
306319
});
307320

308321
describe('persmissions single sheet', () => {

0 commit comments

Comments
 (0)