🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
m

mongoose-groups-acl

Mongoose Groups ACL

0.0.1
latest
71

Supply Chain Security

100

Vulnerability

87

Quality

76

Maintenance

100

License

Version published
Weekly downloads
2
100%
Maintainers
1
Weekly downloads
 
Created

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

FAQs

Package last updated on 20 May 2014

Did you know?

Socket

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.

Install

Related posts