abac-backend
An abstract class implementing ABAC's back-end API.
Install
$ npm install abac-backend
Usage
This module exports an abstract BackEnd
class that should be extended and implemented. The subclassed back-end can be used in applications that use ABAC middleware for authorization (via ABAC).
Subclass BackEnd
Create a new CustomBackEnd
constructor which inherits from BackEnd
:
var util = BackEnd = ; { BackEnd;} util;
Implementing can()
can()
is a high order function that calls a yes()
or no()
function after executing a Policy's Rules on the Subject (request
).
BackEndprototype { // Can request perform action?}
Implementing serialize()
serialize()
is a high order function that returns a callback(err, permissions)
function, where permissions is a JavaScript object that maps actions to a boolean value.
BackEndprototype { // Return the permissions for the Subject (`req`).}
Implementing set_policy()
set_policy()
is a function that upserts a policy represented as a key-value pair, where the key is the action and the value is the rule.
BackEndprototype { // Upsert action and rule.}
Tests
$ npm install
$ npm test
License
Copyright (c) 2014 Stevo <http://github.com/vovantics/>