How to use ACL' property?
I'm a newer to loopback! when I used acl to deny someone modify model's specified property like this: { "principalType": "ROLE", "principalId": "admin", "permission": "DENY", "accessType": "READ", "property":"title" }
"admin" is a role I added, "title" is a model's(Post) property, when I access the route GET " /post", the response data also have "title" property? why? If I won't somebody modify this property ,how can I do?
the "property" is the name of the model remote method (ex. find create upsert count) more info here http://docs.strongloop.com/display/LB/Model+definition+JSON+file#ModeldefinitionJSONfile-ACLs
if you set ACL like this
{
"principalType": "ROLE",
"principalId": "admin",
"permission": "DENY",
"accessType": "READ",
"property":"find"
}
It means the user that have "admin" role can't call "GET /model"
http://docs.strongloop.com/display/LB/Defining+remote+hooks the last example on the link show you how to prevent password from being sent to client
and It will be useful for you in the future http://docs.strongloop.com/display/LB/Model+hooks
If you don't want to any body modify the value of title one of lastest two links above can help you solved. I'm not sure which one.
THX, I find "property" could be a property on a model in the loopback document. I find it on the http://docs.strongloop.com/display/LB/Model+definition+JSON+file . "property Specifies a property/method/relation on a given model. It further constrains where the ACL applies."
I can't use "principalId": "$owner", it doesn't work. Please tell me why ?
@bluestaralone The $owner role is used to check if a target model instance is owned by the logged in user. The target model needs to have a belongsTo relation to the user model.
@raymondfeng: what if the target model is extended from User built-in model, do I need to do implement any relation? If it's required, what should correct definition for this relation?
@raymondfeng: It's ok now, but i can't find records that belong to a logged user. (method GET, remote method /Books) => db.Books.find(); it said that "Authorization Required"