Skip to content

Commit b71d03f

Browse files
committed
Add #117 to Adobe Infra
1 parent 9e7ed76 commit b71d03f

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/routes/config.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ export async function postConfig({ req, env, daCtx }) {
2323
}
2424

2525
export async function getConfig({ env, daCtx }) {
26-
// // TODO maybe we should turn the order around?
27-
// if (!hasPermission(daCtx, 'CONFIG', 'read', true)) {
28-
// const key = daCtx.key.startsWith('/') ? daCtx.key : `/${daCtx.key}`
29-
// if (!hasPermission(daCtx, key, 'read', true)) { // TODO
30-
// return { status: 403 };
31-
// }
26+
if (!hasPermission(daCtx, 'CONFIG', 'read', true)) {
27+
return { status: 403 };
28+
}
3229
return getKv(env, daCtx);
3330
}

test/routes/config.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ describe('Config', () => {
110110
);
111111

112112
const res = await getConfig({ env, daCtx: ctx });
113-
assert.strictEqual(getKVCalled.length, 1, "Should always have get permission on config");
113+
assert.strictEqual(getKVCalled.length, 0, "Should not have read permission on config");
114+
assert.strictEqual(res.status, 403);
114115

115116
const res2 = await postConfig({ req, env, daCtx: ctx });
116117
assert.strictEqual(res2.status, 403);

0 commit comments

Comments
 (0)