EventBridge target -> AppSync mutation -> subscription multi-tenant application event authorization

0

I am building a multi-tenant application and would like to use EventBridge targets to trigger an AppSync mutation. My question is how do I allow a user to only see events they are authorized to see? Would that be a resolver on the subscription? EventBridge would be calling the mutation for all users and with the 2000 rule limit, I can't imagine that I'd need or want to set up a separate target for every user.

1 Answer
1
Accepted Answer

Hi,

You can use Enhanced subscription filtering to define what events have to be sent to each connected user.

Real-time data security documentation demonstrates how to use a subscription's toUser parameter for event filtering.

If you would like to avoid using subscription parameters for the filtering configuration, you can review AppSync enhanced subscription filter Pull Request for a demonstration of using username from the connected user's IAM identity context. Note that IAM identity information was used for the demo code simplicity - you can certainly refactor the code to support other AppSync authorization schemas if needed.

All in all, your implementation can look like this:

  • EventBridge event should have some user specific information that you can filter on, e.g. userId
  • Mutation will accept that field as one of its parameters and forward it to the mutation's response object
  • Subscription resolver will configure enhanced filtering for the subscription to match that user information field from the mutation response object with a field that is available on the current security context

Kind regards,

AWS
answered 19 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions