-
Notifications
You must be signed in to change notification settings - Fork 57
Description
When setting up entities for authorization using nestjs-query I've had a few issues that have tripped me up. It would be good to get some confirmation if there's already a known way to get these working or what if what I want conflicts with overall vision for the library. If these are just missing functionalities, I'll see If I can address any of them with a PR.
Issue 1 - Creation authorization.
I was hoping that I could prevent users creating a resource in a configuration that conflicts with the authorization filter.
I have managed to triage this in my own project by extending the query service to use the authorization filters with the inbuilt applyFilter
on the create-dto. I think an option could be passed to the query-service to enable this behaviour (or the default behaviour)
Issue 2 - Related Creation Authorization
If we accept that the above is desired, I'd love an inbuilt way to prevent things being related to items that you don't have permissions to, I'm not sure what the implementation of this would be and at the moment I just allow this to happen which wouldn't be too big of a problem except for the next issue.
Issue 3 - Inferring data through relation filters
Once you have a filterable relation set up it's possible to construct queries that leak
information about the items even if you don't have permission to that item but have permissions to a related item.
As per my example you can ask for subtasks where task meets condition X
and it will not consider your permission to the tasks so you can find out that tasks meeting condition X
exist in the system even if you don't have permission to any of them.
When joining relationships, I believe we need to apply the authorization filters to the join.
Here's a repo to demonstrate the issue: https://github.com/Smtih/netjs-query-auth-issues/blob/main/test/issue-3.e2e-spec.ts