简体   繁体   中英

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

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM