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
已提问 4 个月前498 查看次数
2 回答
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
已回答 4 个月前
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
已回答 4 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则