Closed pr1ze closed 3 years ago
@pr1ze You are correct that the subscription does seem to be created with IAM instead of User Pools as the authorization type. However, DataStore doesn't currently support using multiple auth type on a model, so the use case you have here won't work as you are expecting. If you remove the { allow: private, provider: iam }
rule, it should work. We are working to improve this soon, but that should be the resolution for now.
@amhinson Does the Documentation state that the DataStore does not support that? Cause reading about the auth directive, one really gets the impression that this is an acceptable model.
I cant remove IAM - then i cannot call the API from my lambda functions.
Can you point me to where it's documented, that the DataStore only supports a single auth type? But if it is not documented, then this is not just something that needs improvement. Then it's a critical issue. It concerns me how many production systems that might be running now, where people are capable of seeing each others sensible data.
Hey @pr1ze, we're currently in the process of improving our docs around this use case.
In the meantime, please try the following:
./models/schema.js
in your text editormodels.CreditCard.attributes[1].rules
This will prevent DataStore from attempting to authenticate the subscriptions with IAM in your app, but you will still be able to authenticate with IAM from your Lambda function.
Please note that you will need to make this manual change each time after running amplify codegen models
.
You can also apply more fine-grained control over which operations are permitted for each of the auth rules you have configured. For example:
@auth(rules: [
{ allow: owner, operations: [create, read, update, delete] },
{ allow: groups, groups: ["administrators"], operations: [update, delete] },
{ allow: private, provider: iam, operations: [create, update, delete] }
])
This will prevent the iam users from subscribing to any mutations on this model.
This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help
channels or Discussions for those types of questions.
Describe the bug Users are able too see others data, when they have an active subscription and someone else created a entity via AppSync.
To Reproduce
Graphql:
Having two different cognito users logged in on each of their device (Seen on iphone), and do:
When one user do DataStore.save({the credit card}) it pops into the DataStore of the other user (With a different username / sub / cognito id).
Closing the app, and do a fresh start removes the entry. So it does not seems like the "sync" has the error, but the subscription does.
Expected behavior The other users should not get the sensible data as the @auth mode is owner.
Code Snippet I do not know if it's related to this: https://github.com/aws-amplify/amplify-js/issues/6990 But i think the subscription is setup with IAM
The generated subscriptions does however have the owner input field:
What is Configured?
React native app - package.json:
aws-exports.js
How amplify is configured in App.tsx
Smartphone (please complete the following information):