Angular spring boot and aws cognito integration

Viewed 760

I am new to the aws environment and I need your help.

I'm working on a project with:

-on the frontend: an angular app  deployed on S3 and accessible via cloudfront

-on the backend: a monolithic application with spring boot and deployed on beanstalk

-authentication: aws cognito

-a database on RDS to store some informations about the user as the username and the role, 
the other informations are kept in aws cognito as user attributes like name, email, tel...

So my questions are:

-Where shoud we make a call to cognito to authenticate the user? in the frontend or make a rest call to the backend and it will call itself aws?

-Do we need api gateway with this configuration?

Please help me!

1 Answers

The most efficient way is to check the authentication on the backend, and put your frontend behind a gateway. On the frontend side you can maintain a sessionId in cookies and when user navigates to frontend, they go through the gateway which validates the session and if invalid, then it will redirect user to login. After a successful login, gateway will redirect user to frontend. All API requests go through gateway as well which retrieves the session details and token to use for API calls

Related