Skip static ACL entries that don't match the property
This commit is contained in:
parent
905fbf4267
commit
242b44ed2b
|
@ -255,14 +255,17 @@ ACL.getStaticACLs = function getStaticACLs(model, property) {
|
||||||
var staticACLs = [];
|
var staticACLs = [];
|
||||||
if (modelClass && modelClass.settings.acls) {
|
if (modelClass && modelClass.settings.acls) {
|
||||||
modelClass.settings.acls.forEach(function (acl) {
|
modelClass.settings.acls.forEach(function (acl) {
|
||||||
staticACLs.push(new ACL({
|
if (!acl.property || acl.property === ACL.ALL
|
||||||
model: model,
|
|| property === acl.property) {
|
||||||
property: acl.property || ACL.ALL,
|
staticACLs.push(new ACL({
|
||||||
principalType: acl.principalType,
|
model: model,
|
||||||
principalId: acl.principalId, // TODO: Should it be a name?
|
property: acl.property || ACL.ALL,
|
||||||
accessType: acl.accessType || ACL.ALL,
|
principalType: acl.principalType,
|
||||||
permission: acl.permission
|
principalId: acl.principalId, // TODO: Should it be a name?
|
||||||
}));
|
accessType: acl.accessType || ACL.ALL,
|
||||||
|
permission: acl.permission
|
||||||
|
}));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var prop = modelClass &&
|
var prop = modelClass &&
|
||||||
|
|
|
@ -227,6 +227,33 @@ describe('security ACLs', function () {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should filter static ACLs by model/property", function() {
|
||||||
|
var Model1 = ds.createModel('Model1', {
|
||||||
|
name: {
|
||||||
|
type: String,
|
||||||
|
acls: [
|
||||||
|
{principalType: ACL.USER, principalId: 'u001',
|
||||||
|
accessType: ACL.WRITE, permission: ACL.DENY},
|
||||||
|
{principalType: ACL.USER, principalId: 'u001',
|
||||||
|
accessType: ACL.ALL, permission: ACL.ALLOW}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
acls: [
|
||||||
|
{principalType: ACL.USER, principalId: 'u001', property: 'name',
|
||||||
|
accessType: ACL.ALL, permission: ACL.ALLOW},
|
||||||
|
{principalType: ACL.USER, principalId: 'u002', property: 'findOne',
|
||||||
|
accessType: ACL.ALL, permission: ACL.ALLOW}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
var staticACLs = ACL.getStaticACLs('Model1', 'name');
|
||||||
|
assert(staticACLs.length === 3);
|
||||||
|
|
||||||
|
staticACLs = ACL.getStaticACLs('Model1', 'findOne');
|
||||||
|
assert(staticACLs.length === 1);
|
||||||
|
});
|
||||||
|
|
||||||
it("should check access against LDL, ACL, and Role", function () {
|
it("should check access against LDL, ACL, and Role", function () {
|
||||||
// var log = console.log;
|
// var log = console.log;
|
||||||
var log = function() {};
|
var log = function() {};
|
||||||
|
|
Loading…
Reference in New Issue