Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    autherpublic

    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.

    Keywords

    none

    install

    npm i auther

    Downloadsweekly downloads

    16

    version

    0.1.0

    license

    none

    homepage

    github.com

    repository

    githubgithub

    last publish

    collaborators

    • avatar