Skip to content

NOT PRODUCTION READY ABAC authorization module for nodeJS written in Typescript

License

Notifications You must be signed in to change notification settings

QuickStyles/AbacApe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AbacApe

Simple Attribute Based Access Control Module for NodeJS

Core Features

  • Simple, Chainable, API.
  • Fully Tested
  • TypeScript Support

Installing

npm -i abacape

Usage

import AbacApe from 'abacape';

class Primate {}
class Food {}
const environment = {};

const AA = new AbacApe();
const PrimateAA = AA.init(Primate);
PrimateAA.createConditionsFor(Food, environment, {
  isBanana: {
    fn:(primate, food, environment) => {
      return food.name === 'Banana';
    },
    err_msg: 'food is not Banana';
  }
});
const PrimateFoodAA = PrimateAA.createPolicyFor(Food, environment);
PrimateFoodAA.action('eat', (conditions) => {
  if(conditions.isBanana()) {
    return true;
  } else {
    return conditions.errors;
  }
});

const lemur = new Primate();
const banana = new Food();
banana.name = 'Banana';

AA.can(lemur).eat(banana); // returns true

const apple = new Food();
apple.name = 'Apple';

AA.can(lemur).eat(apple); // returns [new Error('food is not Banana')]

Authors

License

Distributed under the MIT license. See LICENSE for more information.

Contributing...

Details coming soon.

About

NOT PRODUCTION READY ABAC authorization module for nodeJS written in Typescript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published