node_acl icon indicating copy to clipboard operation
node_acl copied to clipboard

acl is not allowing me to access the resource to which I have given permission

Open pdl761 opened this issue 9 years ago • 12 comments

var acl = require(acl); acl = new acl(new acl.mongodbBackend(app.db), logger); // logger(defined with log files) and app.db(defined with database)

acl.allow('member', ['/api/customer'], '*', function(err){ logger.info("Roles added on /api/customer"); // Not getting called });

acl.addUserRoles('5503fe166f495ec914000007', 'member', function(err){ logger.info("Role assigned to user"); // Not getting called }); // '"5503fe166f495ec914000007" This is an entityID picked from mongodb and in middleware I am gettign the same userId under "req".

app.get('/api/customer', acl.middleware(),function(req, res, next){...}); Here middle ware is not leeting me allow to access the resource '/api/customer'

Can you please tell where I am going wrong ?

pdl761 avatar Aug 13 '15 07:08 pdl761

which collection it is referring to when this function self.db.collection, in add function under mongodb-backend.js , gets called.

Does it user meta, resources, roles, users defined under options.bucket variable or it uses some mongodb collection to store or fetch value?

If Yes, then how it works means how it stores value under options.bucket and how it getAsync() and end Async() with it ----------------------------------------------------------- OR ---------------------------------------------------------------

If No, then where we have to define the mongodb collection name so that it can save the value into mongodb and fetch when ever it wants?

pdl761 avatar Aug 13 '15 07:08 pdl761

What is happening to the function which is being pushed into transaction array in acl/lib/mongodb-backend.js line number 118?

Please reply as soon as possible?

pdl761 avatar Aug 13 '15 10:08 pdl761

I had just changed this acl = new acl(new acl.mongodbBackend(app.db), logger); with this acl = new acl(new acl.memoryBackend()); and it was working fine please help me in solving this issue.

CAN you provide me mongodb structure being implemented fro saving values of meta, resource, parents, roles, users, permissions. It will be helpful for me.

pdl761 avatar Aug 13 '15 13:08 pdl761

can you try using a different backend, such as memory, just to debug and see if the problem is mongo related or something else?

manast avatar Aug 13 '15 16:08 manast

Ya problem is with mongobackend 

I tried using memorybackend and its working fine. 

But dont getting how to use mongodbbackend appropriately.

Please just once have a look into github. I had mentioned details over there 

Sent from Yahoo Mail on Android

From:"Manuel Astudillo" [email protected] Date:Thu, 13 Aug, 2015 at 22:09 Subject:Re: [node_acl] acl is not allowing me to access the resource to which I have given permission (#141)

can you try using a different backend, such as memory, just to debug and see if the problem is mongo related or something else?

— Reply to this email directly or view it on GitHub.

pdl761 avatar Aug 13 '15 16:08 pdl761

I am not really sure what is the problems you are having but If the callback at for example allow is not being called then there is a good chance that the mongo connection is not correct. If you have verified that the connection works, then If I were you I would debug the mongo backend to see what is going on: https://github.com/OptimalBits/node_acl/blob/master/lib/mongodb-backend.js

manast avatar Aug 13 '15 16:08 manast

Connection seems to be OK ...... I had checked and is ng the same all else where and you rlare also correct , allow function callback is in t getting called. 

Can you give a good example of mongodbbackend instance with its proper parameter passing criteria. 

One more thing when I put acl.allow() with its proper parameters. It says all the things are undefined I.e all values under bucket didn't get defined

I am also sure mongodbbackend connection is not working because I am not getting how properly pass parameters.

And one more thing who can a person add dynamic user I'd in acl.allow as that parameter doesn't allow function in its back end.

I have so many questions . can you add me on Google chats or give me yours so that it twill be easy to chat.

My email I'd is [email protected]

Sent from Yahoo Mail on Android

From:"Manuel Astudillo" [email protected] Date:Thu, 13 Aug, 2015 at 22:24 Subject:Re: [node_acl] acl is not allowing me to access the resource to which I have given permission (#141)

I am not really sure what is the problems you are having but If the callback at for example allow`is not being called then there is a good chance that the mongo connection is not correct. If you have verified that the connection works, then If I were you I would debug the mongo backend to see what is going on: https://github.com/OptimalBits/node_acl/blob/master/lib/mongodb-backend.js

— Reply to this email directly or view it on GitHub.

pdl761 avatar Aug 13 '15 17:08 pdl761

sorry but I am not able to provide the kind of support that you are requesting...

manast avatar Aug 13 '15 17:08 manast

Ok, sorry for that.

Ok just tell me for the allow that how person will get userId dynamically inside allow first parameter. As backend check is there tht it can only be string and number. So can you add a dynamic fuction for it also

pdl761 avatar Aug 13 '15 17:08 pdl761

Do i have to make schema for all roles, permissiona, users, parents, resouces to store and fetch value. If yes what will be the achema for each type

pdl761 avatar Aug 13 '15 17:08 pdl761

All the backends work exactly the same, if it works with the memory backend you don't need to do anything special with the other backends.

manast avatar Aug 13 '15 17:08 manast

same issue for me... *while i am using memorybackend * acl = new acl(new acl.memoryBackend(),logger()); acl.allow([ { roles:['member'], allows:[{resources:['/login/updateprofile'],permissions:['get','post']},] }]

In case mongodbbackend. mongoose.connect("mongodb://localhost:27017/acltest"); var db = mongoose.connection; var acl= new acl(new acl.mongodbBackend(db,'acl_',true),logger());

*collection name is *- "acl_resources" , in this acl_resources what are the columns should be there.

*_insert data : *_db.acl_resources.insert({roles:['member'],allows:[{resources:['/login/updateprofile'],permissions:['get','post']}]})

then, acl.allowedPermissions("32ad90e0-c5bb-11e5-a516-c526dcf562ca", '/login/updateprofile', function(err, obj){} when i access the api thorugh post man, I am getting following.. -DEBUG- Requesting get on /login/updateprofile by user 32ad90e0-c5bb-11e5-a516-c526dcf562ca if trace in mongodb-backend.js it stops here it self { _bucketname: 'users', key: '32ad90e0-c5bb-11e5-a516-c526dcf562ca' } searchParamsundefined

not entering into the
this.db.collection(this.prefix + collName,function(err,collection){...}

could you please tell me, what is the issue.

rams0404 avatar Jan 29 '16 13:01 rams0404