Skip to content

wejs/we-core-acl

Repository files navigation

we-core-acl

npm version Build Status Code Climate Coverage Status

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

About

Simple and powerfull access control list (ACL) module, works with any data source and is based in Drupal ACL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors