vincezk / authorization Goto Github PK
View Code? Open in Web Editor NEWAn Object Oriented Authorization Framework for Node.js
License: MIT License
An Object Oriented Authorization Framework for Node.js
License: MIT License
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.
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.
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.