Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
guardhouse
Advanced tools
A flexible access control permissions framework
GuardHouse is designed to make the creation and processing of complex access control restrictions using an easy to understand and store JSON data format.
npm install guardhouse
var guest_acl = {
api: {
account: true,
users: {
read: true
},
'*': false
}
};
var admin_acl = {
api: true,
admin: true,
'*': true
};
var guardhouse = require('guardhouse');
guardhouse.can(guest_acl, 'admin.user.delete');
// -> False
guardhouse.can(admin_acl, 'admin.user.delete');
// -> True
var securedFunction = guardhouse.wrap('admin.functions', someFunction);
securedFunction.auth(guest_acl)();
// -> throws an error
securedFunction.can(guest_acl);
// -> False
securedFunction.auth(admin_acl)(params);
// -> someFunction(params)
GuardHouse includes a powerful permission merging engine which allows partial permissions to be granted to a user, or revoked, in a non-destructive manner. This simplifies common permission management tasks considerably.
var guardhouse = require('guardhouse');
guardhouse.grant(user_acl, {
a: {
b: true
}
});
guardhouse.revoke(user_acl, {
a: {
c: false
}
});
GuardHouse supports a number of customization options which influence its behaviour, including blacklist/whitelist modes, custom rule parsing logic and a number of other features.
var guardhouse = require('guardhouse');
// Set to true for blacklist mode
guardhouse.options.default = false;
// Change to '/' for easy use with web paths
guardhouse.options.targetProcessor = guardhouse.PathProcessor('.');
GuardHouse comes with a customizable target processor which is capable of parsing standard paths with customizable delimiters. It is possible to create your own processor if you wish, provided it follows the convention layed out below.
function CustomPathProcessor(path) {
return path.split(':'); // Must return an array of path segments
}
It is often useful to provide access control for web services and APIs. GuardHouse can easily be integrated with Express using a middleware like the following.
var GuardHouse = require('guardhouse');
GuardHouse.options.targetProcessor = GuardHouse.PathProcessor('/');
app.use(authenticationMiddleware);
app.use(function(req, res, next) {
if(!req.user)
return res.json(401, { error: 'You have not provided a valid set of credentials.' });
if(!Guardhouse.can(req.user.permissions, req.path))
return res.json(403, { error: 'You do not have permission to access this API feature.' });
next();
});
This module is made available under the MIT Licence. You can read the full licence in the LICENCE file.
FAQs
A flexible access control framework for Node.js
The npm package guardhouse receives a total of 1 weekly downloads. As such, guardhouse popularity was classified as not popular.
We found that guardhouse demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.