Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions examples/abac_not_using_policy_model.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act, eft

[policy_effect]
e = some(where (p.eft == allow)) && !some(where (p.eft == deny))

[matchers]
m = r.sub == r.obj.Owner
4 changes: 4 additions & 0 deletions examples/abac_rule_effect_policy.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
p, alice, /data1, read, deny
p, alice, /data1, write, allow
p, bob, /data2, write, deny
p, bob, /data2, read, allow
12 changes: 12 additions & 0 deletions test/model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,18 @@ test('TestABACModel', async () => {
await testEnforce(e, 'bob', data2, 'write', true);
});

test('TestABACNotUsingPolicy', async () => {
const e = await newEnforcer('examples/abac_not_using_policy_model.conf', 'examples/abac_rule_effect_policy.csv');

const data1 = new TestResource('data1', 'alice');
const data2 = new TestResource('data2', 'bob');

await testEnforce(e, 'alice', data1, 'read', true);
await testEnforce(e, 'alice', data1, 'write', true);
await testEnforce(e, 'alice', data2, 'read', false);
await testEnforce(e, 'alice', data2, 'write', false);
});

test('TestKeyMatchModel', async () => {
const e = await newEnforcer('examples/keymatch_model.conf', 'examples/keymatch_policy.csv');

Expand Down