Auth allows update for items from different owners
I'm trying to create an amplify API that allows users to store the profile information in a User table in Dynamo DB. I'm using @auth directive to set owner for the and want to make sure users can only update their own profile. My schema is as follows where ID is the ID from my cognito user pool:
type User
@model(subscriptions: { level: public })
@auth(
rules: [
{ allow: public, provider: iam, operations: [read] }
{
allow: owner
ownerField: "id"
identityClaim: "sub"
operations: [read, create, update]
}
{ allow: groups, groups: ["CommunityAdmin"] }
]
)
@key(fields: ["id"])
@key(
name: "byUsername"
fields: ["username"]
queryField: "userByUsername"
) {
id: ID!
identityId: String
email: String!
username: String!
about: String
}
From the appsync console I'm logged in as a user from my user pool and if I try to perform following update mutation, it will allow me to update another user's about field:
mutation {
updateUser(input: {
id:"<SOME OTHER USER ID>",
about:"Test update"
}) {
id
username
about
}
}
How can setup @auth so only the owner can only update their own profile?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@shivangp Looking into this. Will try to duplicate and resolve.
from the appsync console I'm logged in as a user from my user pool and if I try to perform following update mutation, it will allow me to update another user's about field:
Does the user that you're using in AppSync console belong to CommunityAdmin? If the user does not belong to this group, they would not be allowed to update any record other than the one they own.
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 for those types of questions.