How to use AWS Cognito with cookie sessions?

0

I have read this article:Stop using JWTs!.

I am new to AWS Cognito and OAuth2. I am currently using passportjs to manage my authentication and authorization the storing user sessions in DynamoDB. How can I use sessions with AWS cognito? Does AWS Cognito store session data in Cognito removing the need of using a database to store the session data?

Does this article give the solution I am looking for? I have read it but have not fully understood it. I have seen it talking about JWTs.

Gaita
asked 3 months ago456 views
2 Answers
1

Hi, Gaita

AWS Cognito provides its own user management and authentication service, and it includes a feature for managing user sessions. Unlike PassportJS with DynamoDB where you manage sessions by storing them in a database, AWS Cognito handles session management internally.

When a user signs in using AWS Cognito, it issues JWTs that contain information about the user and the authentication status. These JWTs can be used to manage user sessions without the need for external storage.

Here's a general overview of how you can handle sessions with AWS Cognito:

User Sign-In: Users sign in using AWS Cognito, and upon successful authentication, Cognito issues JWTs.

JWTs for Sessions: The JWTs contain claims about the user, such as identity information and authentication status. These tokens are typically valid for a certain duration (configured in Cognito), and you can use them to identify and authenticate users.

Handling Session Expiry: You need to handle token expiration appropriately. When a token expires, users need to re-authenticate.

Logout: AWS Cognito provides a logout endpoint. When users log out, you can call this endpoint to invalidate their session.

Token Validation: When your server receives a request, you can validate the JWT to ensure it hasn't been tampered with and is still valid.

profile picture
hoylem
answered 3 months ago
1

Hi Gaita

I wont stored the session password on the browser , we are just integration with jwt authenication from cognito and aws lambda . Just you need to replace with client id and cognito domain url configuration details as mention in below client_id: "<your client ID from Cognito>" cogntiourl : "<your App Client Cognito domain>/oauth2/token",

profile picture
Jagan
answered 3 months 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