Fully managed authentication, authorization, and user management service designed for use with web and mobile apps.
Users can sign in directly with a username and password or through a third party, such as Facebook, Amazon, or Google
Two main components:
User pools: User directories that provide sign-up and sign-in options for your app users
Users can also sign in through social identity providers such as Google, Facebook, Login for Amazon, or Sign in with Apple, and through SAML 2.0 identity providers.
Identity pools: Enable you to grant your users access to other AWS services
AWS credentials
Federated identities
Unauthenticated guests
User and identity pools can be used separately or together
Because Google federated identities work for both Android and IOS .
If you're allowing unauthenticated users, you can retrieve a unique Amazon Cognito identifier (identity ID) for your end-user immediately.
Supports multiple login providers
Amazon Cognito has a synchronization feature that you can use to synchronize any changed data on one device to all other devices owned by the user.
The Amazon Cognito Streams feature enables you to automatically stream user state data from Amazon Cognito to Amazon Kinesis which can then be streamed to a data warehouse tool such as Amazon Redshift for further analysis.
By doing that, you can do real-time processing on changes users are making to that data. This data is visualized on powerful dashboards that you can use to gain insights about how your users are using your applications.
Steps:
Click the name of the identity pool
Click Manage Identity Pools. The Manage Federated Identities page appears.
Click Cognito Streams to expand it.
In the Stream name dropdown menu, select the name of an existing Kinesis stream. Alternatively, click Create stream to create one, entering a stream name and the number of shards.
In the Publish role dropdown menu, select the IAM role that grants Amazon Cognito permission to publish your stream. Click Create role to create or modify the roles associated with your identity pool.
Click Save Changes.
The Amazon Cognito Events feature enables you to intercept changes made to an Amazon Cognito dataset.
Trigger an AWS Lambda function so that you can make business logic decisions and modify the data when necessary.
You also have programmatic access to the sync store so that you can make changes to the data stored in Amazon Cognito on behalf of your users on an as-needed basis.
Your application users can sign in directly through a user pool, or federate through a third-party IdP.
The user pool manages the overhead of handling the tokens that are returned from social sign-in through Facebook, Google, and Login with Amazon, and from OIDC and SAML IdPs.
With the built-in hosted web UI, Amazon Cognito provides token handling and management for authenticated users from all identity providers, so your backend systems can standardize on one set of user pool tokens.
User gets authenticated by SAML-based third-party identity provider & gets a token.
Amazon Cognito identity pool provides AWS credentials based upon these tokens.
Applications can access AWS services using these credentials.
Tokens provided by these servers will be exchanged with the Amazon Cognito identity pool to get AWS credentials.
Using these credentials, authenticated users accessing this web application will be able to upload data to Amazon DynamoDB.
Identity store
An identity store for all your apps and users.
Your users can sign in through the following:
Social identity providers such as Google, Facebook, and Login with Amazon
Enterprise identity providers, such as Microsoft Active Directory, using SAML 2.0
Access control
With Amazon Cognito identity pools, you can create methods to grant user access to your AWS resources.
Support of multiple compliance programs
Advanced security features to protect your users.
Integration (Op)
Integration with AWS services
Integration with external identify providers (IdPs) such as Google, Facebook, Sign in with Apple)
Microsoft Active Directory integration
Security (Op)
Data encrypted at rest and in transit; compliant with standards such as the following:
Payment card industry ( PCI) data security standards (DSS)
System and Organization Controls (SOC)
International Organization for Standardization (ISO) 9001
Standards-based authentication (OAuth 2.0, SAML 2.0, OpenID Connect)
Multi-factor authentication (MFA)
A user pool is a user directory in Amazon Cognito.
With a user pool, your users can sign in to your web or mobile app through Amazon Cognito.
Your users can also sign in through social identity providers like Facebook or Login with Amazon, and through SAML identity providers.
Whether your users sign in directly or through a third party, all members of the user pool have a directory profile that you can access through an SDK.
Choose how the user will sign in, such as options for verifying email, phone number, or user name.
Sign-up and sign-in services.
A built-in, customizable web UI to sign in users.
Customized workflows and user migration through Lambda triggers.
User directory management and user profiles.
Security features such as multi-factor authentication (MFA), checks for compromised credentials, account takeover protection, and phone and email verification.
Each user needs at least one MFA factor such as SMS or TOTP set up to sign in.
Require attributes for signing up and creating a user profile, such as email, birthdate, picture, custom attributes, and more.
Specify policies (for example, password strength, require administrator for signup, and set expiration of temp passwords).
Handles the IdP interactions for you
Provides profiles to manage users
Provides OIDC Connect and OAuth2.0 standard tokens
Priced per monthly active user
Enable multi-factor authentication (MFA) and remembering user devices.
Set options for recovering user accounts.
Set options for sending (SMS) and custom emails.
Add tags so that you can categorize and manage user pools.
Specify application clients with access to the user pool. App clients will receive a unique ID and an optional secret key to access the user pool.
Set up customized workflows with triggers. You can select AWS Lambda functions to run with certain events (for example, pre-sign-up, post authentication).
Attributes
Attributes are pieces of information that help you identify individual users, such as name, email, and phone number.
You get a set of default attributes, called standard attributes, with all user pools.
You can also add custom attributes to your user pool definition in the AWS Management Console.
Groups
Use groups to create collections of users to manage their permissions or to represent different types of users.
You can assign an (IAM) role to a group to define the permissions for members of a group.
Because a user can belong to more than one group, each group can be assigned a precedence.
Zero is the top precedence value.
Groups with over groups with higher or null precedence values.
If a user belongs to two or more groups, the group with the lowest precedence value has the IAM role applied to the cognito:preferred_role claim in the user's ID token.
Scope
A level of access that an application can request to a resource.
Developers can create their own OAuth 2.0 resource servers and define custom scopes in them. Custom scopes can then be associated with a client.
Custom scopes are added in the scope claim in the access token.
Token
Amazon Cognito tokens are of JSON Web Token (JWT) format. JWT tokens have three sections:
Header – How to verify a token with encryption algorithm (alg) and the key ID (kid).
Payload – Encoded information about the claim of the key.
The ID token contains encoded user information, such as cognito: username, email, or phone number.
The access token contains information about the authenticated user, including cognito: groups, username, and scope.
Sections:
Sub – Unique identifier for authenticated user
Aud – client_id that is used in the user authentication
token_use– Purpose of the token, such as ID
auth_time– When the authentication occurred
origin_jti– JWT identifier that indicates where the authentication happened.
Jti – Unique identifier of the JWT token
Signature – Calculated based on the header and payload of the token.
Token Example:
////Header////
{
"kid" : "1234example="
"alg" : "RS256",
}
////Payload////
{
"sub": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"aud": "xxxxxxxxxxxxexample",
"email_verified": true,
"token_use": "id",
"auth_time": 1500009400,
"iss": "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_example",
"cognito:username": “StudentA",
"exp": 1500013000,
"given_name": "StudentA",
"iat": 1500009400,
"email": "StudentA@example.com",
"jti": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"origin_jti": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
}
////Signature////
HMACSHA256(base64UrlEncode(header) + "." + base64UrlEncode(payload), {secret})
With identity pools, you can authenticate users through an external identity provider.
Identity pools provide temporary security credentials to access your application’s backend resources in AWS or any service behind Amazon API Gateway.
Exchanges tokens from authenticated users for AWS credentials to access resources such as Amazon S3 or Amazon DynamoDB.
To manage permissions, you can define rules for mapping users to different IAM roles.
The match type can be Equals, NotEqual, StartsWith, or Contains.
Rules are evaluated in order, and the IAM role for the first matching rule is used, unless CustomRoleArn is specified to override the order.
Provides an ID to uniquely identify users.
Provides AWS credentials for accessing resources on behalf of users
Supports rules to map users to different IAM roles
Credentials can be provided to federation authenticated guests and users
Free to use
Creating and configure a user pool
Use the Amazon Cognito console, CLI/SDK, or API to create a user pool.
You need user pool ID, client ID, and any client secret (if set any) for the rest of the configuration.
Use the API Gateway console, CLI/SDK, or API to create an API Gateway authorizer of COGNITO_USER_POOLS authorizer type with the chosen user pool.
Use the API Gateway console, CLI/SDK, or API to enable the authorizer on selected API methods.
For Token source, use Authorization as the header name to pass the identity or access token that is returned by Amazon Cognito when a user signs in successfully.
Use the API Gateway Console or third-party tools to test the invocation by supplying an identity token that's provisioned from the user pool.
Calling API methods
Use the Amazon Cognito CLI/SDK or API to sign a user into the chosen user pool, and obtain an identity token or access token.
Use a client-specific framework to call the deployed API Gateway API and supply the appropriate token in the Authorization header.
API Gateway validates tokens with the Amazon Cognito user pool.
Invoke backend AWS services.
Based on the Amazon Cognito security architecture, your application connects to an identity provider (IdP) to get an access token to identify your user.
The IdP can be Facebook, Login with Amazon, Google+. Or you can use you own IdP or any OpenID Connect (OIDC) compatible source.
This token is then passed to an Amazon Cognito identity pool and exchanged for a short-lived AWS access token.
This action allows your application to assume an IAM role and inherit the permissions granted to that particular role.
When authenticated, your application can do anything that the IAM role grants permission to do; for example, access DynamoDB or Amazon S3 directly, if you allow it.
Amazon Cognito also assigns an Amazon Cognito identifier similar to this, which uniquely identifies the user for the lifetime of the application.
Content