Coder Social home page Coder Social logo

vincezk / authorization Goto Github PK

View Code? Open in Web Editor NEW
33.0 33.0 9.0 622 KB

An Object Oriented Authorization Framework for Node.js

License: MIT License

JavaScript 100.00%
acl authorization authorization-profiles identity nodejs passport security

authorization's People

Contributors

vincezk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

authorization's Issues

[Request] Deny Permission

First, I really like this authorization model; simple yet flexible. One thing that doesn't seem to be present is an ability to "deny" permission. The "Exclude" setting of the "Option" field isn't the same, because it actually is designed to say, "Allow everything else". If another authorization object "Includes" an authorization field value that was "excluded" by another authorization object, the permission will be granted. A deny model would allow a developer\user to express that even if an authorization field value is "allowed" in other authorization objects, the denial of permission overrides the allow.

I poked around in the code a little bit to see how it might be implemented. The one thought I had that I felt was probably accurate, is that the expression of "Allow" vs "Deny" could probably be best expressed at the "Authorization Object" level. The part I couldn't figure out was how to bring it all together in the "check" function without over-complicating it.

[Question] Compiled Auth in JWT token

I use JWT token to ensure stateless authentication.

Does the compiled profile can be set in the token and pass over the network in each HTTP request in term of weight?

Thanks,
Serge.

[New Request] Variable in auth file...

Hi,

Is it possible to have values replaced at runtime?

For instance: the user can only update his own profile

Then I would expect his ID to be part of the authorization value.

Let me know.

Thanks,
Serge.

[Bug] Possible undefined in check method of authorization object

Hello,

First of all, I would like to thank you for developing this package which is very convenient. It's easy to define role based permission.

In my use case, I have two role: admin and basic.

The admin can do anything: manage user and message (CRUD operation).
The user can only read messages.

The authorization profile could be:

Admin
[
    {   "AuthObject": "user",
        "AuthFieldValue":{
            "Action": ["Create","Read","Update,"Delete"]
        }
    },
    {
        "AuthObject": "blog",
        "AuthFieldValue":{
            "Action": ["Create","Read","Update,"Delete"]
        }
    }
]
Basic
[
    {
        "AuthObject": "blog",
        "AuthFieldValue":{
            "Action": ["Read"]
        }
    }
]

With this example, when I want to check if a basic user can manage a user, an undefined will be thrown in the check method because no permission will be found (grantedPermission is undefined):

var grantedPermission =
        find(this.profile, function(authorization){
            return authorization.AuthObject === authObject;
        });

    return every(requiredPermission,function(value, field){
        let _grantedValue = grantedPermission.AuthFieldValue[field];
        if(_grantedValue){

It could be great to return before calling the every function.

Thanks

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.