We are designing a collaboration software db structure and using MEAN stack, and my lack of ACL permissions experience prompted this question.
High level, the software is for collaborators and auditors to work/view tasks in projects.
The 'Project' entity/table in MongoDB is used to manage the ACL groups. Each project has a 'Collaborator' array of user pointers and a 'Auditor' array of user pointers. Users in the Collaborators array are added to the projects 'Collaborator' ACL group with read/write access and users in Auditors array are added to the projects auditors acl group, which has read only.
There is another entity called 'Task' in MongoDB and each task is tied to one, and only one, project. A project can have multiple tasks. The task get's the projects Collaborate ACL group and Auditor ACL group added to it.
So that all works great. Now, user Bob is a collaborator on project A and an auditor on project B. If Bob queries the database for tasks, he'll get back both tasks he can read/write on (project A) and tasks he can read only (project B). But how does the front end know which tasks he has write permissions and which he has read only? Because the front end needs to show 'edit' button only next to tasks user has write permissions for.
I see in ACL permissions, I can do a call to check if a user has write privileges on an individual object, but that's per object and would be performance prohibitive to do an additional call per object, even if it was done on the server before sending the initial query response.
Can I query the Task entity group in mongo with a filter like 'AND current user permissions contain Write'? Or how should this be handled?