Skip to content

enniel/acler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ACLer

Minimalistic ACL implementation for privileges management in JS

NPM Version GitHub license Build Status Coverage Status

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.

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published