0.1.4 • Published 3 years ago

aclatraz v0.1.4

Weekly downloads
127
License
MIT
Repository
github
Last release
3 years ago

Aclatraz GitHub package.json dynamic

Travis (.com) Codecov npm npm bundle size

Simple dependency-free package for ACL. It can handle hundreds of roles easily.

Install

npm install aclatraz

How it works

  1. Create the rules (they can be roles as well)
  2. Load them into Aclatraz
  3. Generate permission tokens based on rules
  4. Verify token

TypeScript example

import { Aclatraz } from 'aclatraz';

// Create an ACL instance. Don't forget to store
// somewhere the rules (preferably in DB, or in a file)
const acl = new Aclatraz([
  {
    id: 1,
    slug: 'READ_USER',
  },
]);

// Add new rule on the fly
acl.addRule({
  id: 2,
  slug: 'CREATE_USER',
  name: 'Protect registration with this rule',
});

// User with this token can access id: 1 rule
const permissionToken = acl.generateAclCode([1]);

console.log(acl.verify(permissionToken, 1)); // true
console.log(acl.verify(permissionToken, 2)); // false

How to use as an express middleware

Soon...

How to use as a fastify middleware

Soon...

How to use as a NestJS guard

Soon...

0.1.4

3 years ago

0.1.3

3 years ago

0.1.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago