Fetching with predicates ignores models auth rules (DataStore)
See original GitHub issueDescribe the bug Using predicates with DataStore, auth rules seem to be totally ignored if you are setting a model only accessible by the owner, and the query is call using predicates the auth owner rules is ignored and every item from the DB that fulfills the predicate logic and all items that satisfy the predicates are returned even those owned by another user.
To Reproduce Steps to reproduce the behavior:
- Create a model with simple owner base auth rule Ex.
type Item @model @auth(rules: [{ allow: owner }]) {...}
- Generate your model and deploy your schema (pm run amplify-modelgen and amplify push)
- Create Items from 2 different users
- Now query those the Items using predicates Ex.
await DataStore.query(Property, (c) => c.available("eq", false))
- The response will return all the Items with key “available” false, even those from created by the other user
Expected behavior Predicates should not violate models auth rules, returning only the filtered owner models
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
DataStore - Syncing data to cloud - JavaScript - Amplify Docs
This will clear the contents of your local store, reevaluate your sync expressions and re-sync the data from the cloud, applying all of...
Read more >Lazy loading & nested query predicates for AWS Amplify ...
DataStore provides frontend app developers the ability to build real-time apps ... You can now query based on conditions of related models.
Read more >Transaction locking and row versioning guide - SQL Server
In a relational database, all rules must be applied to the transaction's modifications to maintain all data integrity.
Read more >RDF Semantic Graph Overview - Oracle Help Center
For information about using rules and rulebases for inferencing, ... Statements are expressed in triples: {subject or resource, predicate or property, ...
Read more >Google Cloud release notes | Documentation
SPARK-40481: Ignore stage fetch failure caused by decommissioned executor. ... Automatic IAM database authentication for Cloud SQL for MySQL is now ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi there @ashika01 it works like a charm! I’m leaving a hint here just in case someone needs to use it
@manueliglesias this could be closed if you want.
Hi @alexandprivate
Every operation you do on the DataStore happens locally first. What you are seeing is that your local data still has data from another user.
Here the recomendation is to clear the DataStore when a user signs out/in with:
I noticed you brought this up in https://github.com/aws-amplify/amplify-js/issues/6108#issuecomment-664751765 too I’ll add a note there pointing here.