Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wejs/we-core-acl
Simple and powerfull access control list (ACL) module, works with any data source and is based in Drupal ACL
https://github.com/wejs/we-core-acl
Last synced: about 2 months ago
JSON representation
Simple and powerfull access control list (ACL) module, works with any data source and is based in Drupal ACL
- Host: GitHub
- URL: https://github.com/wejs/we-core-acl
- Owner: wejs
- License: mit
- Created: 2016-03-27T15:06:46.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-09-09T20:16:13.000Z (over 5 years ago)
- Last Synced: 2024-11-06T07:47:50.971Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 23.4 KB
- Stars: 6
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# we-core-acl
[![npm version](https://badge.fury.io/js/we-core-acl.svg)](https://badge.fury.io/js/we-core-acl) [![Build Status](https://travis-ci.org/wejs/we-core-acl.svg?branch=master)](https://travis-ci.org/wejs/we-core-acl) [![Code Climate](https://codeclimate.com/github/wejs/we-core-acl/badges/gpa.svg)](https://codeclimate.com/github/wejs/we-core-acl) [![Coverage Status](https://coveralls.io/repos/github/wejs/we-core-acl/badge.svg?branch=master)](https://coveralls.io/github/wejs/we-core-acl?branch=master)
> Simple and powerfull access control list (ACL) module exported from we.js core
## Installation
```sh
npm install --save we-core-acl
```## Usage
Test it in your browser:
https://tonicdev.com/albertosouza/tonic-npm-we-core-acl
### Example
```js
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 useif (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
}});
```
## LicenseMIT © [Alberto Souza](http://albertosouza.net)