Skip to content
This repository has been archived by the owner on Apr 10, 2018. It is now read-only.
/ auth-rbac Public archive

An authentication/authorization library that implements RBAC

License

Notifications You must be signed in to change notification settings

alex94cp/auth-rbac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

auth-rbac

Build Status Dependencies Coverage Status Join the chat at https://gitter.im/alex94puchades/auth-rbac

RBAC-based authorization library for node

Installation

$ npm install auth-rbac

Sample Usage

var authRbac = require('auth-rbac');
var express = require('express');

var User = require('./models/user');
var Role = require('./models/role');

var auth = authRbac({
	getUser: function(req, cb) {
		cb(null, req.user);
	},
	
	userGetRole: function(user, cb) {
		Role.findById(user.role, cb);
	},
	
	roleHasPrivilege: function(role, priv, cb) {
		cb(null, role.privileges.indexOf(priv) !== -1);
	},
});

var app = express();
app.use(authRbac.identify(auth));
app.get('/users',
	authRbac.requirePrivilege('user:enum')
	function(req, res) {
		return res.sendStatus(200);
	});

About

An authentication/authorization library that implements RBAC

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published