You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var acl = require("acl");
var node_acl = new acl(new acl.memoryBackend());
//01 - Bind roles to resources
node_acl.allow('role01', '/resource01/:param1', 'get');
//02 - Middleware to assign roles to user
- Some code
//03 - Normalizing routes to ignore params
exports.HandlingParamsonAuthorization = function(req, res, next) {
var parts = req.path.split('/');
var i = 0;
var newparts;
for (i = 0; i < parts.length; i++) {
if (parts[i] == '57cc79487a6643572fe5813b') {
parts[i] = ':param' + i;
}
}
newparts = parts.join('/');
console.log(newparts);
//Checking if this route has the required permission
node_acl.isAllowed(req.user, newparts, req.method, function(err, res) {
if (res) {
console.log(res);
next();
}
})
next();
}
//04 - Enforce this to all routes
app.use(node_acl.middleware());
It fails to work when i do GET /resource01/57cc79487a6643572fe5813b it shows /resource01/:param1 but shows the error "insufficient permissions". Please help.
The text was updated successfully, but these errors were encountered:
and also set 1 optional parameter (to check for permission for resource /resource01 and not /resource01/57cc79487a6643572fe5813b). Obviously you should register the middleware according to paths and number of parameters.
It fails to work when i do
GET /resource01/57cc79487a6643572fe5813b
it shows/resource01/:param1
but shows the error "insufficient permissions". Please help.The text was updated successfully, but these errors were encountered: