mongoose-groups-acl

0.0.1 • Public • Published

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); // => ['read', 'write', 'delete']

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

Readme

Keywords

none

Package Sidebar

Install

npm i mongoose-groups-acl

Weekly Downloads

1

Version

0.0.1

License

none

Last publish

Collaborators

  • rpavez