Skip to content
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

LiveQuery roles, poiner permissions are misssing #5839

Open
nangyal opened this issue Jul 22, 2019 · 10 comments
Open

LiveQuery roles, poiner permissions are misssing #5839

nangyal opened this issue Jul 22, 2019 · 10 comments
Labels
type:feature New feature or improvement of existing feature

Comments

@nangyal
Copy link

nangyal commented Jul 22, 2019

Is your feature request related to a problem? Please describe.
The LiveQuery Permission management not handle
roles and poiner permissions

Describe the solution you'd like

Describe alternatives you've considered

Additional context

// TODO: handle roles permissions

@davimacedo
Copy link
Member

@nangyal thanks for reporting. Would you be willed to tackle this one?

@mullwaden
Copy link

Commented this in #5393 as well which I think has a better description of what is going wrong.

We are having an issue with this and @ridem in #5393 has made a perfect analysis of what is wrong. Would be fun to make a PR on how to fix it but I am not sure how, I believe it could be quite tricky.

Why it is important to fix:

  • When adding a user to a role it might take up to an hour before the cache is reset and live queries work again
  • when removing a user from a role she might have access to data which she should not have access to which is a bit of a security issue

I made a small workaround it is not optimal but as long as we have the liveQueryServer and the parseServer on the same server it will work:

  • create the server as usual const liveQueryServer = ParseServer.createLiveQueryServer(httpServer)
  • In _Role add the following to beforeSave liveQueryServer.authCache.reset()

This clears the cache as soon as a role is changed. It could easily be made smarter by fetching the users that belong to that role and only removing or editing those rows in the authCache

@qwertyway
Copy link

Thank you @mullwaden

I've been facing exactly the same issue with roles and fresh added users as described at #5393
I've spent a couple of days investigating the issue, found live query cache, but wasn't sure how to configure or reset it

You solution helped, I'll use it for now. I hope the final fix will be more efficient

@dblythy
Copy link
Member

dblythy commented Mar 16, 2021

Is this in relation to an LQ event won't be fired if the related Role is updated? Or is this something else?

E.g, if

role.getUsers().add(user);
await role.save();

Is called, related LQ objects with the role should fire an enter or leave event.

@mullwaden
Copy link

@dblythy the issue is that the cache can be outdated. So lets say a user is added to a role with RoleX and then tries to fetch a database row with the acl = { read: RoleX }. Regular fetching will work, but the live updates will fail because the liveQuery cache is outdated, i.e. the user has not yet been added to the cache of that particular role.

@nangyal
Copy link
Author

nangyal commented Jul 26, 2021

2 years past and still not fixed :)

@dblythy
Copy link
Member

dblythy commented Jul 27, 2021

@nangyal Have you tried putting the LQ trigger on the role class?

@nangyal
Copy link
Author

nangyal commented Oct 25, 2021

No, I solved it a different way [redacted]

@mtrezza mtrezza added type:feature New feature or improvement of existing feature and removed type:improvement labels Dec 6, 2021
@dblythy
Copy link
Member

dblythy commented Jun 7, 2022

I note the code snippet referenced refers to the _matchesCLP function, so are you saying that if you have roles in CLP Parse Live Query doesn't correctly handle it?

It's a little vague for what the issue actually is - and LiveQuery (to my testing) does support role based ACLs.

@mullwaden I have reopened #5393 as I have been able to replicate the issue of role cache not updating when getUsers.add(user) is called.

@mtrezza
Copy link
Member

mtrezza commented Jun 7, 2022

@nangyal I redacted your comment, as it referred to a potential vulnerability. We have opened an internal issue for further investigation. If you have any questions please reach out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature or improvement of existing feature
Projects
None yet
Development

No branches or pull requests

6 participants