Amazon Cognito User Pools and Identity Pools Explained

Amazon Cognito User Pools and Identity Pools Explained

With the proliferation of smartphones in our connected world, more and more developers are quickly deploying their applications on the cloud. One of the first challenges in developing applications is allowing users to log in and authenticate on your applications. There are multiple stages involved in user verification and most of these are not visible from the end-user. AWS provides an easy solution for this situation.

User Identity verification is at the core of Amazon Cognito. It provides solutions for three key areas of user identification: 

  1. Authentication – provides users sign-up and sign-in options. Enables support for federation with Enterprise Identities (Microsoft AD), or Social Identities (Amazon, Facebook, Google, etc.)
  2. Authorization – sets of permission or operations allowed for a user. It provides fine-grained access control to resources. 
  3. User Management – allows management of user lifecycles, such as importing users, onboarding users, disabling users, and storing and managing user profiles.

In this post, we’ll talk about Cognito User Pools and Identity Pools, including an overview of how they are used to provide authentication and authorization functionalities that can be integrated on your mobile app.

Amazon Cognito User Pools

Amazon Cognito User Pools are used for authentication. To verify your user’s identity, you will want to have a way for them to login using username/passwords or federated login using Identity Providers such as Amazon, Facebook, Google, or a SAML supported authentication such as Microsoft Active Directory. You can configure these Identity Providers on Cognito, and it will handle the interactions with these providers so you only have to worry about handling the Authentication tokens on your app.

No alt text provided for this image

With Cognito User Pools, you can provide sign-up and sign-in functionality for your mobile or web app users. You don’t have to build or maintain any server infrastructure on which users will authenticate. 

This diagram shows how authentication is handled with Cognito User Pools:

No alt text provided for this image
  1. Users send authentication requests to Cognito User Pools. 
  2. The Cognito user pool verifies the identity of the user or sends the request to Identity Providers such as Facebook, Google, Amazon, or SAML authentication (with Microsoft AD).
  3. The Cognito User Pool Token is sent back to the user. 
  4. The person can then use this token to access your backend APIs hosted on your EC2 clusters or in API Gateway and Lambda.

If you want a quick login page, you can even use the pre-built login UI provided by Amazon Cognito which you just have to integrate on your application.

No alt text provided for this image

On the Amazon Cognito User Pool page, you can also manage users if you need to. You can reset the password, disable/enable users, and enroll/delete users or other actions needed for User Management. 

Amazon Cognito Identity Pools

Cognito Identity Pools (Federated Identities) provides different functionality compared to User Pools. Identity Pools are used for User Authorization. You can create unique identities for your users and federate them with your identity providers. Using identity pools, users can obtain temporary AWS credentials to access other AWS services. 

Identity Pools can be thought of as the actual mechanism authorizing access to AWS resources. When you create Identity Pools, think of it as defining who is allowed to get AWS credentials and use those credentials to access AWS resources.

This diagram shows how authorization is handled with Cognito Identity Pools:

No alt text provided for this image
  1. The web app or mobile app sends its authentication token to Cognito Identity Pools. The token can come from a valid Identity Provider, like Cognito User Pools, Amazon, or Facebook. 
  2. Cognito Identity Pool exchanges the user authentication token for temporary AWS credentials to access resources such as S3 or DynamoDB. AWS credentials are sent back to the user. 
  3. The temporary AWS credentials will be used to access AWS resources. 

You can define rules in Cognito Identity Pools for mapping users to different IAM roles to provide fine-grain permissions. 

Here’s a table summary describing Cognito User Pool and Identity Pool:

No alt text provided for this image

For more free blogs and cheat sheets like this, visit the Tutorials Dojo site:

https://tutorialsdojo.com/aws-cheat-sheets/

https://tutorialsdojo.com/blog/

This article is authored by: Kenneth Samonte, our resident AWS whiz/contributor.

Sources:

https://aws.amazon.com/premiumsupport/knowledge-center/cognito-user-pools-identity-pools/

https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html

https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-identity.html

https://docs.aws.amazon.com/cognito/latest/developerguide/authentication.html

https://docs.aws.amazon.com/cognito/latest/developerguide/switching-identities.html

Michael Miller

Director of Engineering | Multi-Cloud Architect (AWS, Azure & GCP) | AI/ML | Zero Trust | FinOps | FinTech | Mentor | CMMI

4 年

Your explanation in the Solutions Architect Practice exams really helped me understand this service so much more!!

Prateek Nayak

Director - Full Stack Engineering | Engineering Chapter Leader | Digital Platforms Strategist and Builder | Problem Solver | Patent Holder | Lifelong Learner

4 年

Well written, Thank you. Sharing it for my connections.

Sergey Tsvetkov

ИТ Архитектор(exEPAM, exSber, exVTB), учу Софт Скиллам | 1 на 1 и Корпоративные тренинги по Софтам | Вы можете все (только секцию About не читайте)

4 年

Well put, Jon, thank you.

Paramesh .A

Enterprise Solutions Architect(API/Digital Integration/Cloud Solution)

4 年

Quick check , How APIGW validate those token?

回复

要查看或添加评论,请登录

Jon Bonso的更多文章

社区洞察

其他会员也浏览了