-
Notifications
You must be signed in to change notification settings - Fork 108
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
Examples leak data - i can see what other users booked - or is this on purpose? #109
Comments
Hi @nickluger. Thanks for bringing this up. You're right, the permission setup is not yet fully implemented. Would be great if someone would like to take a stab at this - maybe based on graphql-shield? |
@schickling, I am on it! |
Hey @schickling, @maticzav, Has there been any progress with this one? I've encountered a similar issue with a project I'm working on. It'd be super useful for us GraphQLNoobs to see how to mask certain fields at arbitrary query depths given some permissions. In this example it would involve removing the "bookings" field from place or perhaps limiting the selection on the relation to specified public fields. I'm using graphql-shield but don't see an obvious way to filter the incoming selection or verify it given the incoming user's permissions without hard coding the selection passed to prisma-binding. I imagine one possible solution might be to create a masking type but again not sure how to implement this. Any help appreciated! |
Hey 👋, I started playing with this a bit but came to a strange conclusion. GraphQL Shield serves as means to prevent unwanted requests. Data leaks don't happen because of bad queries but rather because of wrong data manipulation. I think it could be beneficial to add GraphQL Shield to the example but hardly believe it will solve the data leaking problem. |
I found a solution to this, there are a couple of options. The first is more flexible, allowing you to get dynamic or filtered results for your resolvers. The second just returns null for the resolver when certain conditions are not met.
The resolver could probably be written better to improve performance but you get the idea.
I hope this helps someone! |
One can also introduce two different data models We are using a similar approach currently with You just need to take care, that, if you use |
I considered that approach too @nickluger. It is beneficial in terms of being a more accurate representation to the client via introspection. My thoughts on the potential downsides:
There is no 'right' approach here I think and it really depends on the use case and how you expect that resolver tree to behave throughout the schema lifespan. |
I strongly support the 2nd approach suggested by @daveols, using See here: dotansimha/graphql-binding#67 The 1st approach has the disadvantage of mingling resolvers with imperative authorization code, as described here https://www.prisma.io/blog/graphql-directive-permissions-authorization-made-easy-54c076b5368e/. |
Just a very blant remark, this does mean that you cannot currently implement prisma for a production application... or is there a concrete solution soon to be released. |
We're using the solution suggested by @daveols now, succesfully for a production app. You could try that, too. |
@voordev this by no means that prisma is not ready for a production application. Just means we need to add this to this implementation. We’ll add some shield soon |
For example, if i have a booking, i can see who else booked the same place and when. I can fetch their email, personal data etc.
Response
Hmm interesting, Karl will also be at Mushroom Dome!
This is a problem i ran into, not only in this server example, but also in my own and other peoples server code. As soon as we have cyclic model references, hiding data becomes very complex.
The text was updated successfully, but these errors were encountered: