How can I secure a AWS Beanstalk API that is receiving requests from AWS Amplify?

Viewed 206

I have set up an API on AWS Elastic Beanstalk and a Front-End environment on AWS Amplify, these 2 are connected and the front-end is receiving the data from the API calls.

The problem is, the API is open to the public. I'm looking for a way to whitelist (or any other way of securing it) AWS Amplify so only authorized users can make API calls through the front-end.

I'm currently using AWS Cognito as an authentication method for my AWS Amplify app.

Thank you!

1 Answers

You should use the access token returned by cognito to secure your API by setting the Authorization: Bearer <access_token> header with the JWT. Your backend then verifies the JWT to ensure it came from cognito before processing the request. This verification should be handled by a library of your choice, https://jwt.io has a good list.

Related