New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

rac

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rac

Resource Access Control - resource based access control that allows you to define your resources through code and assign permissions for each role to that resource. This way you can easly add new roles and allow them access to resources without making any

latest
Source
npmnpm
Version
0.0.13
Version published
Maintainers
1
Created
Source

RAC

Resource based access control for nodejs

Rac uses mongodb for storing resource information and redisdb for caching resources for runtime.

It requires property roleId to be loaded in request object. For example :

req.session = {};
req.session.roleId = 2;

So you have to have middleware in front of rac that loads role for every request

#Quick start

var redisClient = require('redis').createClient(6379, 'localhost'),
	MongoClient = MongoClient = require('mongodb').MongoClient;
	mongoclient = new MongoClient(new Server("localhost", 27017), {native_parser: true});
;
var Rac = require('rac'); //load rac
var rac = Rac(mongoClient, redisClient);

rac.defineResource({
	uri : '/users/:userId',
	verb : 'GET',
	name : 'Read user',
	description : 'API endpoint that reads all the users',
	roles : [
	    {
	        roleId : 2,
	        constraints : ["isOwner"]
	    }
	]
});

app.get('/users/:userId', roleLoadingMiddleware(), rac.middleware('/users/:userId'), function(req, res){
    //your code	
});

Keywords

Nodejs;Access

FAQs

Package last updated on 21 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts