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
1 change: 1 addition & 0 deletions common/models/acl.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ module.exports = function(ACL) {
var permissionOrder = AccessContext.permissionOrder[permission];
if (candidateOrder > permissionOrder) {
permission = candidate.permission;
break;
}
}
}
Expand Down
35 changes: 35 additions & 0 deletions test/acl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,41 @@ describe('security ACLs', function() {
// });
});

it('should order ACL entries based on the matching score even with wildcard req', function() {
var acls = [
{
'model': 'account',
'accessType': '*',
'permission': 'DENY',
'principalType': 'ROLE',
'principalId': '$everyone',
},
{
'model': 'account',
'accessType': '*',
'permission': 'ALLOW',
'principalType': 'ROLE',
'principalId': '$owner',
}];
var req = {
model: 'account',
property: '*',
accessType: 'WRITE',
};

acls = acls.map(function(a) { return new ACL(a); });

var perm = ACL.resolvePermission(acls, req);
// remove the registry from AccessRequest instance to ease asserting.
// Check the above test case for more info.
delete perm.registry;
assert.deepEqual(perm, {model: 'account',
property: '*',
accessType: 'WRITE',
permission: 'ALLOW',
methodNames: []});
});

it('should allow access to models for the given principal by wildcard', function() {
// jscs:disable validateIndentation
ACL.create({
Expand Down