auther

0.1.0 • Public • Published

Build Status

Auther

Simple Authorization middleware for express.js.

Validates access to resources based on express route parameters.

installation

npm install auther

usage

var auther = require('auther');


...

app.get('/company/:cid', auther.isAuthorized('admin', 'managers'), companyRoutes.get)	
...


	
// With passport.js
var setupFacebook = function() {
	...

	autheur.initUser(user, rolesToResourcesHash, function(err) {

	...
}



var rolesToResourcesHash = {
	admin: function(user, cb) {
		var roleToResources = {}

		roleToResources['cid'] = [companyId];

		done(null, roleToResources);
	}, 
	...
}

Authorization

For each role in your application, implament a load_XXX function. First argument is the user object created in the authentication phase. Populate the user.AOHash for each of the resource types.

Readme

Keywords

none

Package Sidebar

Install

npm i auther

Weekly Downloads

0

Version

0.1.0

License

none

Last publish

Collaborators

  • anderslarsson