we-core-acl

    1.2.4 • Public • Published

    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

    Install

    npm i we-core-acl

    DownloadsWeekly Downloads

    1

    Version

    1.2.4

    License

    MIT

    Unpacked Size

    13.2 kB

    Total Files

    4

    Last publish

    Collaborators

    • albertosouza