You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/aws/services/cognito.md
+79-50Lines changed: 79 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,5 @@
1
1
---
2
2
title: "Cognito"
3
-
linkTitle: "Cognito"
4
3
description: Get started with Cognito on LocalStack
5
4
tags: ["Base"]
6
5
persistence: supported
@@ -13,7 +12,7 @@ Cognito enables developers to add user sign-up, sign-in, and access control func
13
12
Cognito supports various authentication methods, including social identity providers, SAML-based identity providers, and custom authentication flows.
14
13
15
14
LocalStack allows you to use the Cognito APIs in your local environment to manage authentication and access control for your local application and resources.
16
-
The supported APIs are available on our [Cognito Identity coverage page]({{< ref "coverage_cognito-identity" >}}) and [Cognito User Pools coverage page]({{< ref "coverage_cognito-idp" >}}), which provides information on the extent of Cognito's integration with LocalStack.
15
+
The supported APIs are available on our [Cognito Identity coverage page]() and [Cognito User Pools coverage page](), which provides information on the extent of Cognito's integration with LocalStack.
17
16
18
17
## Getting started
19
18
@@ -27,9 +26,9 @@ We will demonstrate how you can create a Cognito user pool and client, and then
27
26
To create a user pool, you can use the [`CreateUserPool`](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateUserPool.html) API call.
28
27
The following command creates a user pool named `test`:
29
28
30
-
{{< command >}}
31
-
$ awslocal cognito-idp create-user-pool --pool-name test
32
-
{{< /command >}}
29
+
```bash
30
+
awslocal cognito-idp create-user-pool --pool-name test
31
+
```
33
32
34
33
You can see an output similar to the following:
35
34
@@ -66,15 +65,15 @@ You can see an output similar to the following:
66
65
You will need the user pool's `id` for further operations.
67
66
Save it in a `pool_id` variable:
68
67
69
-
{{< command >}}
70
-
$ pool_id=<your-pool-id>
71
-
{{< /command >}}
68
+
```bash
69
+
pool_id=<your-pool-id>
70
+
```
72
71
73
72
Alternatively, you can use JSON processor like [`jq`](https://stedolan.github.io/jq/) to extract the essential information right from the outset when creating a pool.
74
73
75
-
{{< command >}}
76
-
$ pool_id=$(awslocal cognito-idp create-user-pool --pool-name test | jq -rc ".UserPool.Id")
@@ -83,9 +82,9 @@ You will require the ID of the newly created client for the subsequent steps.
83
82
You can use the [`CreateUserPoolClient`](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateUserPoolClient.html) for both client creation and extraction of the corresponding ID.
You also have the possibility to create a Cognito user pool client with a predefined ID by specifying a `ClientName` with the specific format: `_custom_id_:<custom_client_id>`.
@@ -140,7 +149,7 @@ You can see an output similar to the following:
140
149
141
150
Once the user is successfully created, a confirmation code will be generated.
142
151
This code can be found in the LocalStack container logs (as shown below).
143
-
Additionally, if you have [SMTP configured]({{< ref "configuration#emails" >}}), the confirmation code can be optionally sent via email for enhanced convenience and user experience.
152
+
Additionally, if you have [SMTP configured](/aws/capabilities/config/configuration/#emails), the confirmation code can be optionally sent via email for enhanced convenience and user experience.
144
153
145
154
```bash
146
155
INFO:localstack_ext.services.cognito.cognito_idp_api: Confirmation code for Cognito user example_user: 125796
@@ -150,18 +159,23 @@ DEBUG:localstack_ext.bootstrap.email_utils: Sending confirmation code via email
150
159
You can confirm the user with the activation code, using the [`ConfirmSignUp`](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ConfirmSignUp.html) API.
151
160
Execute the following command:
152
161
153
-
{{< command >}}
154
-
$ awslocal cognito-idp confirm-sign-up \
162
+
```bash
163
+
awslocal cognito-idp confirm-sign-up \
155
164
--client-id $client_id \
156
165
--username example_user \
157
166
--confirmation-code <received-confirmation-code>
158
-
{{< /command >}}
167
+
```
159
168
160
169
Since the above command does not provide a direct response, we need to verify the success of the request by checking the pool.
161
170
Run the following command to use the [`ListUsers`](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUsers.html) API to list the users in the pool:
Upon successful authentication of a non-registered user, Cognito will automatically trigger the migration Lambda function, allowing the user to be added to the pool after migration.
300
324
@@ -310,7 +334,7 @@ Replace `<client_id>` with the ID of your existing user pool client (for example
310
334
311
335
The login form should look similar to the screenshot below:
@@ -338,13 +367,13 @@ The client credentials grant allows for scope-based authorization from a non-int
338
367
Your app can directly request client credentials from the token endpoint to receive an access token.
339
368
340
369
To request the token from the LocalStack URL, use the following endpoint: `://cognito-idp.localhost.localstack.cloud:4566/_aws/cognito-idp/oauth2/token`.
341
-
For additional information on our endpoints, refer to our [Internal Endpoints]({{< ref "/references/internal-endpoints" >}}) documentation.
370
+
For additional information on our endpoints, refer to our [Internal Endpoints]() documentation.
342
371
343
372
If there are multiple user pools, LocalStack identifies the appropriate one by examining the `clientid` of the request.
The LocalStack Web Application provides a Resource Browser for managing Cognito User Pools, and more.
450
479
You can access the Resource Browser by opening the LocalStack Web Application in your browser, navigating to the **Resources** section, and then clicking on **Cognito** under the **Security Identity Compliance** section.
The Resource Browser allows you to perform the following actions:
455
484
@@ -472,4 +501,4 @@ The following code snippets and sample applications provide practical examples o
472
501
473
502
By default, LocalStack's Cognito does not send actual email messages.
474
503
However, if you wish to enable this feature, you will need to provide an email address and configure the corresponding SMTP settings.
475
-
The instructions on configuring the connection parameters of your SMTP server can be found in the [Configuration]({{< ref "configuration#emails" >}}) guide to allow your local Cognito environment to send email notifications.
504
+
The instructions on configuring the connection parameters of your SMTP server can be found in the [Configuration](/aws/capabilities/config/configuration/#emails) guide to allow your local Cognito environment to send email notifications.
0 commit comments