What is Amazon Cognito? - Amazon Cognito

What is Amazon Cognito?

Amazon Cognito is an identity platform for web and mobile apps. It’s a user directory, an authentication server, and an authorization service for OAuth 2.0 access tokens and AWS credentials. With Amazon Cognito, you can authenticate and authorize users from the built-in user directory, from your enterprise directory, and from consumer identity providers like Google and Facebook.

The two components that follow make up Amazon Cognito. They operate independently or in tandem, based on your access needs for your users.

User pools

Create a user pool when you want to authenticate and authorize users to your app or API. User pools are a user directory with both self-service and administrator-driven user creation, management, and authentication. Your user pool can be an independent directory and OIDC identity provider (IdP), and an intermediate service provider (SP) to third-party providers of workforce and customer identities. You can provide single sign-on (SSO) in your app for your organization's workforce identities in SAML 2.0 and OIDC IdPs with user pools. You can also provide SSO in your app for your organization's customer identities in the public OAuth 2.0 identity stores Amazon, Google, Apple and Facebook. For more information about customer identity and access management (CIAM), see What is CIAM?.

User pools don’t require integration with an identity pool. From a user pool, you can issue authenticated JSON web tokens (JWTs) directly to an app, a web server, or an API.

Identity pools

Set up an Amazon Cognito identity pool when you want to authorize authenticated or anonymous users to access your AWS resources. An identity pool issues AWS credentials for your app to serve resources to users. You can authenticate users with a trusted identity provider, like a user pool or a SAML 2.0 service. It can also optionally issue credentials for guest users. Identity pools use both role-based and attribute-based access control to manage your users’ authorization to access your AWS resources.

Identity pools don’t require integration with a user pool. An identity pool can accept authenticated claims directly from both workforce and consumer identity providers.

An Amazon Cognito user pool and identity pool used together

In the diagram that begins this topic, you use Amazon Cognito to authenticate your user and then grant them access to an AWS service.

  1. Your app user signs in through a user pool and receives OAuth 2.0 tokens.

  2. Your app exchanges a user pool token with an identity pool for temporary AWS credentials that you can use with AWS APIs and the AWS Command Line Interface (AWS CLI).

  3. Your app assigns the credentials session to your user, and delivers authorized access to AWS services like Amazon S3 and Amazon DynamoDB.

For more examples that use identity pools and user pools, see Common Amazon Cognito scenarios.

In Amazon Cognito, the security of the cloud obligation of the shared responsibility model is compliant with SOC 1-3, PCI DSS, ISO 27001, and is HIPAA-BAA eligible. You can design your security in the cloud in Amazon Cognito to be compliant with SOC1-3, ISO 27001, and HIPAA-BAA, but not PCI DSS. For more information, see AWS services in scope. See also Regional data considerations.

Features of Amazon Cognito

User pools

An Amazon Cognito user pool is a user directory. With a user pool, your users can sign in to your web or mobile app through Amazon Cognito, or federate through a third-party IdP. Federated and local users have a user profile in your user pool.

Local users are those who signed up or you created directly in your user pool. You can manage and customize these user profiles in the AWS Management Console, an AWS SDK, or the AWS Command Line Interface (AWS CLI).

Amazon Cognito user pools accept tokens and assertions from third-party IdPs, and collect the user attributes into a JWT that it issues to your app. You can standardize your app on one set of JWTs while Amazon Cognito handles the interactions with IdPs, mapping their claims to a central token format.

An Amazon Cognito user pool can be a standalone IdP. Amazon Cognito draws from the OpenID Connect (OIDC) standard to generate JWTs for authentication and authorization. When you sign in local users, your user pool is authoritative for those users. You have access to the following features when you authenticate local users.

  • Implement your own web front-end that calls the Amazon Cognito user pools API to authenticate, authorize, and manage your users.

  • Set up multi-factor authentication (MFA) for your users. Amazon Cognito supports time-based one-time password (TOTP) and SMS message MFA.

  • Secure against access from user accounts that are under malicious control.

  • Create your own custom multi-step authentication flows.

  • Look up users in another directory and migrate them to Amazon Cognito.

An Amazon Cognito user pool can also fulfill a dual role as a service provider (SP) to your IdPs, and an IdP to your app. Amazon Cognito user pools can connect to consumer IdPs like Facebook and Google, or workforce IdPs like Okta and Active Directory Federation Services (ADFS).

With the OAuth 2.0 and OpenID Connect (OIDC) tokens that an Amazon Cognito user pool issues, you can

  • Accept an ID token in your app that authenticates a user, and provides the information that you need to set up the user’s profile

  • Accept an access token in your API with the OIDC scopes that authorize your users’ API calls.

  • Retrieve AWS credentials from an Amazon Cognito identity pool.

Features of Amazon Cognito user pools
Feature Description
OIDC IdP Issue ID tokens to authenticate users
Authorization server Issue access tokens to authorize user access to APIs
SAML 2.0 SP Transform SAML assertions into ID and access tokens
OIDC SP Transform OIDC tokens into ID and access tokens
OAuth 2.0 SP Transform ID tokens from Apple, Facebook, Amazon, or Google to your own ID and access tokens
Authentication frontend service Sign up, manage, and authenticate users with the hosted UI
API support for your own UI Create, manage and authenticate users through API requests in supported AWS SDKs¹
MFA Use SMS messages, TOTPs, or your user's device as an additional authentication factor¹
Security monitoring & response Secure against malicious activity and insecure passwords¹
Customize authentication flows Build your own authentication mechanism, or add custom steps to existing flows¹
Groups Create logical groupings of users, and a hierarchy of IAM role claims when you pass tokens to identity pools
Customize ID tokens Customize your ID tokens with new, modified, and suppressed claims
Customize user attributes Assign values to user attributes and add your own custom attributes

¹ Feature is only available to local users.

For more information about user pools, see Getting started with user pools and the Amazon Cognito user pools API reference.

Identity pools

An identity pool is a collection of unique identifiers, or identities, that you assign to your users or guests and authorize to receive temporary AWS credentials. When you present proof of authentication to an identity pool in the form of the trusted claims from a SAML 2.0, OpenID Connect (OIDC), or OAuth 2.0 social identity provider (IdP), you associate your user with an identity in the identity pool. The token that your identity pool creates for the identity can retrieve temporary session credentials from AWS Security Token Service (AWS STS).

To complement authenticated identities, you can also configure an identity pool to authorize AWS access without IdP authentication. You can offer your own custom proof of authentication, or no authentication. You can grant temporary AWS credentials to any app user who requests them, with unauthenticated identities. Identity pools also accept claims and issue credentials based on your own custom schema, with developer-authenticated identities.

With Amazon Cognito identity pools, you have two ways to integrate with IAM policies in your AWS account. You can use these two features together or individually.

Role-based access control

When your user passes claims to your identity pool, Amazon Cognito chooses the IAM role that it requests. To customize the role’s permissions to your needs, you apply IAM policies to each role. For example, if your user demonstrates that they are in the marketing department, they receive credentials for a role with policies tailored to marketing department access needs. Amazon Cognito can request a default role, a role based on rules that query your user’s claims, or a role based on your user’s group membership in a user pool. You can also configure the role trust policy so that IAM trusts only your identity pool to generate temporary sessions.

Attributes for access control

Your identity pool reads attributes from your user’s claims, and maps them to principal tags in your user’s temporary session. You can then configure your IAM resource-based policies to allow or deny access to resources based on IAM principals that carry the session tags from your identity pool. For example, if your user demonstrates that they are in the marketing department, AWS STS tags their session Department: marketing. Your Amazon S3 bucket permits read operations based on an aws:PrincipalTag condition that requires a value of marketing for the Department tag.

Features of Amazon Cognito identity pools
Feature Description
Amazon Cognito user pool SP Exchange an ID token from your user pool for web identity credentials from AWS STS
SAML 2.0 SP Exchange SAML assertions for web identity credentials from AWS STS
OIDC SP Exchange OIDC tokens for web identity credentials from AWS STS
OAuth 2.0 SP Exchange OAuth tokens from Amazon, Facebook, Google, Apple, and Twitter for web identity credentials from AWS STS
Custom SP With AWS credentials, exchange claims in any format for web identity credentials from AWS STS
Unauthenticated access Issue limited-access web identity credentials from AWS STS without authentication
Role-based access control Choose an IAM role for your authenticated user based on their claims, and configure your roles to only be assumed in the context of your identity pool
Attribute-based access control Convert claims into principal tags for your AWS STS temporary session, and use IAM policies to filter resource access based on principal tags

For more information about identity pools, see Getting started with Amazon Cognito identity pools (federated identities) and the Amazon Cognito identity pools API reference.

Amazon Cognito user pools and identity pools comparison

Feature Description User pools Identity pools
OIDC IdP Issue OIDC ID tokens to authenticate app users
API authorization server Issue access tokens to authorize user access to APIs, databases, and other resources that accept OAuth 2.0 authorization scopes
IAM web identity authorization server Generate tokens that you can exchange with AWS STS for temporary AWS credentials
SAML 2.0 SP & OIDC IdP Issue customized OIDC tokens based on claims from a SAML 2.0 IdP
OIDC SP & OIDC IdP Issue customized OIDC tokens based on claims from an OIDC IdP
OAuth 2.0 SP & OIDC IdP Issue customized OIDC tokens based on scopes from OAuth 2.0 social providers like Apple and Google
SAML 2.0 SP & credentials broker Issue temporary AWS credentials based on claims from a SAML 2.0 IdP
OIDC SP & credentials broker Issue temporary AWS credentials based on claims from an OIDC IdP
OAuth 2.0 SP & credentials broker Issue temporary AWS credentials based on scopes from OAuth 2.0 social providers like Apple and Google
Amazon Cognito user pool SP & credentials broker Issue temporary AWS credentials based on OIDC claims from an Amazon Cognito user pool
Custom SP & credentials broker Issue temporary AWS credentials based on developer IAM authorization
Authentication frontend service Sign up, manage, and authenticate users with the hosted UI
API support for your own authentication UI Create, manage and authenticate users through API requests in supported AWS SDKs¹
MFA Use SMS messages, TOTPs, or your user's device as an additional authentication factor¹
Security monitoring & response Protect against malicious activity and insecure passwords¹
Customize authentication flows Build your own authentication mechanism, or add custom steps to existing flows¹
Groups Create logical groupings of users, and a hierarchy of IAM role claims when you pass tokens to identity pools
Customize ID tokens Customize your ID tokens with new, modified, and suppressed claims
AWS WAF web ACLs Monitor and control requests to your authentication environment with AWS WAF
Customize user attributes Assign values to user attributes and add your own custom attributes
Unauthenticated access Issue limited-access web identity credentials from AWS STS without authentication
Role-based access control Choose an IAM role for your authenticated user based on their claims, and configure your roles to only be assumed in the context of your identity pool
Attribute-based access control Transform user claims into principal tags for your AWS STS temporary session, and use IAM policies to filter resource access based on principal tags

¹ Feature is only available to local users.

Getting started with Amazon Cognito

For a guide to top tasks and where to start, see Getting started with Amazon Cognito.

For videos, articles, documentation, and sample apps, see Amazon Cognito developer resources.

To use Amazon Cognito, you need an AWS account. For more information, see Using the Amazon Cognito console.

Regional availability

Amazon Cognito is available in multiple AWS Regions worldwide. In each Region, Amazon Cognito is distributed across multiple Availability Zones. These Availability Zones are physically isolated from each other, but are united by private, low-latency, high-throughput, and highly redundant network connections. These Availability Zones enable AWS to provide services, including Amazon Cognito, with very high levels of availability and redundancy, while also minimizing latency.

For a list of all the Regions where Amazon Cognito is currently available, see AWS regions and endpoints in the Amazon Web Services General Reference. To learn more about the number of Availability Zones that are available in each Region, see AWS global infrastructure.

Pricing for Amazon Cognito

For information about Amazon Cognito pricing, see Amazon Cognito pricing.