Add menu-level ACS check

This commit is contained in:
Bryan Ashby 2018-08-04 11:49:44 -06:00
parent 475fe596f6
commit 5bd7ecdb88
5 changed files with 80 additions and 28 deletions

View file

@ -51,6 +51,19 @@ class ACS {
return this.check(area.acs, 'download', ACS.Defaults.FileAreaDownload);
}
hasMenuModuleAccess(modInst) {
const acs = _.get(modInst, 'menuConfig.config.acs');
if(!_.isString(acs)) {
return true; // no ACS check req.
}
try {
return checkAcs(acs, { client : this.client } );
} catch(e) {
Log.warn( { exception : e, acs : acs }, 'Exception caught checking ACS');
return false;
}
}
getConditionalValue(condArray, memberName) {
if(!Array.isArray(condArray)) {
// no cond array, just use the value
@ -68,7 +81,7 @@ class ACS {
return false;
}
} else {
return true; // no acs check req.
return true; // no ACS check req.
}
});

View file

@ -127,6 +127,13 @@ module.exports = class MenuStack {
} else {
self.client.log.debug( { menuName : name }, 'Goto menu module');
if(!this.client.acs.hasMenuModuleAccess(modInst)) {
if(cb) {
return cb(Errors.AccessDenied('No access to this menu'));
}
return;
}
//
// If menuFlags were supplied in menu.hjson, they should win over
// anything supplied in code.

View file

@ -116,7 +116,7 @@ exports.getModule = class ShowArtModule extends MenuModule {
if(!area) {
return cb(Errors.DoesNotExist(`No area by areaTag ${key} found`));
}
return cb(null); // :TODO: REM OVE ME
return cb(null); // :TODO: REMOVE ME --- currently NYI
});
}