-
Notifications
You must be signed in to change notification settings - Fork 1.2k
$owner Dynamic Role should be applied to find
filter
#2366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Haha @mitsos1os... I can't get over that profile picture! But I agree, this would be a good feature. |
Edit: I've created a separate feature request #3241 I'm having the same problem. To piggy back on @mitsos1os Posts example, I want to issue a query to find the users last 5 Posts, AND I don't want other users to be able to see that users Posts.
But the $owner ACL doesn't get applied to my find query (src)
I could change and use $authenticated, but then any authenticated user could peek into the GET request being issued and craft their own using the Authenticate header and get someone else's Posts, which is not good. |
Note that there are 2 slightly different demands here:
There's currently WIP on the $owner dynamic role. I'll keep this in mind. At the time being i feel there might be collateral effects resulting from the ACL scoring computation that would prevent in some cases a correct coverage of all users expectations regarding access control (e.g. at the same time filter automatically the posts owned by a user and allow authenticated users to view all posts) In the meantime have you considered implementing a custom role resolver to cover your needs? @bajtos any thoughts on this feature? |
Just for a hint I will tell you what I do to restrict user access to static $owner querying - interacting. When I have some time I was thinking of implementing the owner role to check for the relation to the user document in the same way as |
@mitsos1os : using |
find
filter
This feature request makes total sense. In my personal opinion, it should have been a part of the ACL system from the beginning. @raymondfeng @ritch @superkhau ☝️ something to consider for the next LoopBack version
Now that
@ebarault Have you considered open-sourcing that mixin, so that other LoopBack users could use it too? |
Yes I agree, with the exception that you cannot have the I also like the idea of a configurable mixin for accepting also some options on which actions it should restrict access... @bajtos where would be a good location to share this mixin? |
I would create a new package developed on github.com and published to npmjs.org. You can promote it e.g. in https://github.com/pasindud/awesome-loopback and http://loopback.io/doc/en/community/index.html |
I am closing this issue as a duplicate of much older #343. |
$owner as a dynamic role, gets triggered by instance methods that have the :id route parameter.
I believe that this should also happen in static methods in a similar way.
For example, let's say I have User and Post model. And they are connected through a User hasMany Posts and Posts belongTo User relationships through foreign key userId in Post model.
When requesting /find on Posts and have an ACL for $owner active, it should add to the query parameter the userId property (or one dynamically defined during model setup) in order to only return the logged in user's posts.
The text was updated successfully, but these errors were encountered: