we-core-acl
v1.2.4
Published
Simple and powerfull access control list (ACL) module
Downloads
110
Maintainers
Readme
we-core-acl
Simple and powerfull access control list (ACL) module exported from we.js core
Installation
npm install --save we-core-acl
Usage
Test it in your browser:
https://tonicdev.com/albertosouza/tonic-npm-we-core-acl
Example
var ACL = require('we-core-acl');
var acl = new ACL();
var options = {
config: {
permissions: {
'fly_fast': {
'title': 'Fly super fast'
}
},
// roles with permissions
roles: {
administrator: {
// administrators can do everything and dont need permissions
name: "Administrator"
},
bird: {
name: 'bird',
permissions: []
},
jet: {
name: 'jet',
permissions: [
'fly_fast'
]
}
}
}
}
acl.init(options, function(){
// acl is ready to use
if (acl.can('fly_fast', ['bird'])) {
// can fly fast, this will not run in this example
} else {
// birds cant fly fast
}
if (acl.can('fly_fast', ['jet'])) {
// jet can fly fast
} else {
// this not run in this example
}
if (acl.can('fly_fast', ['jet', 'bird'])) {
// Bird Jets can fly fast
} else {
// this not run in this example
}
});
License
MIT © Alberto Souza