ACL.checkAccessForToken not working properly
hi, i am using ACL.checkAccessForToken to check access of user for models
Acl.checkAccessForToken(socket.client.token,'post','1','updateById',function(err,allowed){ console.log(allowed); }) this works for $owner but not for admin,
"acls": [ { "accessType": "", "principalType": "ROLE", "principalId": "$everyone", "permission": "DENY" }, { "accessType": "", "principalType": "ROLE", "principalId": "$everyone", "permission": "ALLOW", "property": [ "find", "findById" ] }, { "accessType": "", "principalType": "ROLE", "principalId": "$owner", "permission": "ALLOW", "property": [ "updateById" ] }, { "accessType": "", "principalType": "ROLE", "principalId": "admin", "permission": "ALLOW" } ]
"post": { "1": "{"title":"need C++ developers at Houston","content":"urgent requirement. Please contact immediately.","created":"2015-12-04T05:05:18.616Z","skills":["c++","ABAP"],"userId":4,"id":4}", "5": "{"title":"need mean stack developer.","content":"no content","created":"2015-12-08T10:44:13.189Z","skills":["mongo","angular","node","express","strongloop"],"userId":1,"id":5,"isActive":false}", "11": "{"title":"testing 123","content":"","created":"2015-12-08T16:13:22.117Z","location":"telecom","skills":["c++","php"],"userId":2,"id":11}" }
this is working for api but not for the ACL function. i used this function check in server.
this is the debug log loopback:security:access-context principal: {"type":"USER","id":2} +0ms loopback:security:access-context modelName post +0ms loopback:security:access-context modelId 5 +0ms loopback:security:access-context property updateById +0ms loopback:security:access-context method updateById +0ms loopback:security:access-context accessType * +0ms loopback:security:access-context accessToken: +0ms loopback:security:access-context id "b9i6LjvkqAo8HdJMUGuhoX9jEy4AexE1wGEgjEcIHaXZaNOD5JgL0qS5d2dTGRZK" +0ms loopback:security:access-context ttl undefined +0ms loopback:security:access-context getUserId() 2 +0ms loopback:security:access-context isAuthenticated() true +0ms loopback:security:role Model found: {"title":"need mean stack developer.","content":"no content","created":"2015-12-08T10:44:13.189Z","skills":["mongo","angular","node","express","strongloop"],"isActive":false,"id":5,"us erId":1} +4ms loopback:security:role Role found: {"id":1,"name":"admin","created":"2015-12-02T05:29:15.697Z","modified":"2015-12-02T05:29:15.697Z"} +0ms loopback:security:role Role mapping found: {"id":2,"principalType":"USER","principalId":"2","roleId":1} +0ms loopback:security:role isInRole() returns: true +0ms loopback:security:acl The following ACLs were searched: +0ms loopback:security:acl ---ACL--- +0ms loopback:security:acl model post +0ms loopback:security:acl property * +0ms loopback:security:acl principalType ROLE +0ms loopback:security:acl principalId admin +0ms loopback:security:acl accessType * +4ms loopback:security:acl permission ALLOW +0ms loopback:security:acl with score: +0ms 7636 loopback:security:acl ---ACL--- +0ms loopback:security:acl model post +0ms loopback:security:acl property * +0ms loopback:security:acl principalType ROLE +0ms loopback:security:acl principalId $everyone +0ms loopback:security:acl accessType * +0ms loopback:security:acl permission DENY +0ms loopback:security:acl with score: +4ms 7623 loopback:security:acl ---Resolved--- +0ms loopback:security:access-context ---AccessRequest--- +0ms loopback:security:access-context model post +0ms loopback:security:access-context property updateById +0ms loopback:security:access-context accessType * +0ms loopback:security:access-context permission DENY +0ms loopback:security:access-context isWildcard() true +0ms loopback:security:access-context isAllowed() false +0ms
console output : false
looked at the acl model and found it looks for acl in database. looks like i dont have any documents in ACL collection
how to access permissions based on the mode.json? could you please help me quick. thank you in advance
@gshireesh Are you using a database, if so which one?
memory db.
Can you provide a sample repo for me to reproduce the issue?
By default, the ACL REST API is not exposed. To expose it, add the following to models.json: "acl": { "public": true, "options": { "base": "ACL" }, "dataSource": "db" },
See documentation: https://docs.strongloop.com/display/public/LB/ACL+REST+API
@gshireesh Were you able to get it working?
Closing due to inactivity. If you are still running into problems, feel free to leave a comment and I will reopen the issue.