dabit3 / appsync-auth-and-unauth

How to allow both authenticated & unauthenticated access to an API
90 stars 2 forks source link

Limit authorization to owner when using IAM authentication #9

Open kwhitejr opened 5 years ago

kwhitejr commented 5 years ago

Hi @dabit3, thank you providing this auth + unauth example. Can you expand on this concluding comment?

If you'd like to access the unique identity of the logged in user for user authorization & fine grained access control, you can access the $context.identity.cognitoIdentityId) in the resolver.

For example, how do we use $context.identity.cognitoIdentityId to limit a certain mutation to the "owner" of a resource, i.e. the author of a blogpost, as opposed to any signed-in user of the blog site?