mongoose-grops-acl
Usage
var mongoose = require('mongoose');
var acl = require('mongoose-groups-acl');
var ObjectSchema = new mongoose.Schema({ ⦠});
ObjectSchema.plugin(acl.object);
var UserSchema = new mongoose.Schema({ ⦠});
UserSchema.plugin(acl.subject);
Methods
Getting and setting the permissions for a given object:
var user = ā¦;
user.setAccess(object, ['read', 'write', 'delete']);
user.getAccess(object);
We can query for all objects to which a particular subject has access:
Object.withAccess(user, ['read']).exec(function(err, objects) {
...
});
Options
Object
We can specify the path in which the ACL will be stored (by default it will be available at _acl
):
ObjectSchema.plugin(acl.object, {
path: '_acl'
});
There is one special key referred to as the public key. If set, the associated permissions will apply to all subjects:
UserSchema.plugin(acl.subject, {
public: '*'
});
Install
npm install mongoose-groups-acl
Tests
npm test