fix(authz): tighten policy scope enforcement

This commit is contained in:
zouantchaw
2026-03-19 16:48:43 +01:00
parent 2f25d10368
commit a4ac0b2a6b
14 changed files with 743 additions and 30 deletions

View File

@@ -0,0 +1,33 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { can } from '../src/services/policy.js';
test('core actions require tenant scope', async () => {
const allowed = await can(
'core.verification.read',
'verification',
{
uid: 'user-1',
policyContext: {
user: { userId: 'user-1' },
tenant: { tenantId: 'tenant-1' },
},
},
{}
);
const denied = await can(
'core.verification.read',
'verification',
{
uid: 'user-1',
policyContext: {
user: { userId: 'user-1' },
},
},
{}
);
assert.equal(allowed, true);
assert.equal(denied, false);
});