Giter Club home page Giter Club logo

express-authorize's People

Contributors

charleseads avatar docksteaderluke avatar kgraves avatar ribbles avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ferronrsmith

express-authorize's Issues

using the authorizer in a global variable always return Permission Denied

Hi,
I am trying to do the following:

  1. Define express-authorize as global
  2. During login set the permissions of the logged user
  3. When trying to access any REST API use isPermitted to test permissions

express-authorize instance is defined in a separate file like this
var authorizer = require('express-authorize');
module.exports = authorizer;

During login I try to set the default options like this:
authorizer.options.withSubject = {
username: username,
permissions: authorizerPermissions
};
username is the name of the user which logged to the machine
authorizerPermissions is a result of a function which returns array of list items (example: ['configuration:view', 'configuration:delete']

The REST API call looks like this
router.get('/about', authorizer.isPermitted('configuration:view'), function(req, res) {...

Results:
permission check always fail whether a user is permitted or not to access the resource.
if I set the authorizer in the same file which implements the REST API it works ok
so if I place this code
authorizer.options.withSubject = {
username: username,
permissions: authorizerPermissions
};
in the same file of this code
router.get('/about', authorizer.isPermitted('configuration:view'), function(req, res) {...
it will work

If I comment the isPermitted check in the REST API and print the content of authorizer it looks ok, meaning I can see my settings which was set during login.

Any ideas what I am doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.