How to set up ACLs to allow users to access only specific records?

 ̄綄美尐妖づ 提交于 2019-12-22 21:56:34

问题


I'm planning to use Loopback to create an application where users will be able to access only specific records.

Let's say we have a Projects model, with 2 records:

{
    "projects": [
        {
            "project_name": "foo",
            "project_start_date": "2012-10-29T18:25:43.511Z"
        },
        {
            "project_name": "bar",
            "project_start_date": "2012-10-30T18:25:43.511Z"
        }
    ]
}

and that I have 2 users, joe and katie.

I want joe to be able to access only project foo, and katie to be able to access only project bar.

Is this possible at all? If so, how should I go about setting up the ACLs?


回答1:


At the moment, the declarative ACL doesn't support your use case. You need to create afterRemote hook to further check the response. See http://docs.strongloop.com/display/LB/Remote+hooks.




回答2:


You can also play with dynamic roles. See http://docs.strongloop.com/display/public/LB/Defining+and+using+roles#Definingandusingroles-Dynamicroles and similar loopback example: https://github.com/strongloop/loopback-example-access-control/blob/master/common/models/project.json



来源:https://stackoverflow.com/questions/26661968/how-to-set-up-acls-to-allow-users-to-access-only-specific-records

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!