acler

Minimalistic ACL implementation for privileges management in `JS`

  • acler

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
acler
1.0.05 years ago5 years agoMinified + gzip package size for acler in KB

Readme

ACLer
Minimalistic ACL implementation for privileges management in JS

Installation

$ npm i acler --save
or
$ yarn add acler

Usage

// using ES modules
import { check } from 'acler'
// using CommonJS modules
const { check } = require('acler')

const user = {
  get roles () {
    return ['moderator']
  }
}

const can = check('administrator || moderator', role => {
  return user.roles.includes(role)
})

if (!can) {
  throw new Error('You not allowed to this resource.')
}

Syntax

and (&&) - administrator && moderator
or (||) - administrator || moderator
not (!) - administrator && !moderator

Credits

Support

Having trouble? Open an issue!

License

The MIT License (MIT). Please see License File for more information.