Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit 2377c6b

Browse files
committed
Refined modules 0, 1, and 9 instructions
1 parent d06ef3e commit 2377c6b

File tree

12 files changed

+124
-99
lines changed

12 files changed

+124
-99
lines changed

Auth/0_GettingStarted/README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ This section outlines the prerequisites to complete the workshop and instruction
66

77
### AWS Account
88

9-
In order to complete this workshop, you'll need an AWS account and access to
10-
create and manage the AWS services that are used in this workshop, including Cloud9, Cognito, API Gateway, Lambda, and DynamoDB.
9+
In order to complete this workshop, you'll need an AWS account and access to create and manage the AWS services that are used in this workshop, including Cloud9, Cognito, API Gateway, Lambda, DynamoDB, and IAM policies and roles.
1110

1211
The code and instructions in this workshop assume only one participant is using a given AWS account at a time. If you attempt sharing an account with another participant, you will encounter naming conflicts for certain resources. You can work around this by using distinct Regions, but the instructions do not provide details on the changes required to make this work.
1312

@@ -26,8 +25,6 @@ for popular programming languages and the AWS Command Line Interface (CLI)
2625
pre-installed so you don’t need to install files or configure your laptop for
2726
this workshop.
2827

29-
In this workshop, you will use a Cloud9 environment which will have access to the same AWS resources as the user with which you logged into the AWS Management Console.
30-
3128
## Cloud9 IDE Setup
3229

3330
In this section you will launch a CloudFormation stack that will create a a new [Amazon VPC](https://aws.amazon.com/vpc/) environment and a [Cloud9 IDE](https://aws.amazon.com/cloud9/) Instance that you will use in the rest of the workshop.
@@ -53,9 +50,9 @@ Asia Pacific (Sydney) | [![Launch Cloud9 in ap-southeast-2](http://docs.aws.amaz
5350

5451
1. On the Configure Stack Options page, accept all the defaults and click **Next**.
5552

56-
1. Choose to **Acknowledge that the CloudFormation template may create IAM resources with custom names**. Finally, click **Create stack**.
53+
1. On the Review page, review the summary details then click **Create stack**.
5754

58-
1. It will take a few minutes for the Stack to create. Choose the **Stack Info** tab to go to the overall stack status page and wait until the stack is fully launched and shows a status of **CREATE_COMPLETE**. Click the refresh icon to see progress updates.
55+
1. It will take a few minutes for the Stack to create. Choose the **Stack Info** tab to go to the overall stack status page and wait until the stack is fully launched and shows a status of **CREATE_COMPLETE**. Click the refresh icon periodically to see progress update.
5956

6057
1. With the `WildRydes-Cloud9` stack selected, click on the **Outputs** tab and copy the value shown for the `Cloud9IDE` to the clipboard. Open that URL in a new browswer tab to load your IDE environment.
6158

@@ -102,8 +99,8 @@ Keep your AWS Cloud9 IDE opened in a tab throughout this workshop as you'll be u
10299
1. Run the following commands to upgrade your Node.js version to v10
103100

104101
```console
105-
nvm i 10
106-
nvm alias default 10
102+
nvm i 8
103+
nvm alias default 8
107104
```
108105

109106
2. Install the yarn package manager and website dependencies by running the following commands

Auth/1_UserAuthentication/README.md

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Module 1: User Authentication
22

3-
In this module, you will create an Amazon Cognito User Pool and Identity Pool for the wild rydes application.
3+
In this module, you will create an Amazon Cognito User Pool and Identity Pool for the Wild Rydes application.
44
The Cognito User Pool will store user profile information and provide sign-up and sign-in capabilities, with the Cognito Identity Pool providing the ability to assume an Identity and Access Management (IAM) role from within the application.
55

66
Since Wild Rydes is a ride sharing application, a key requirement is that all users must sign-up and sign-in before they're allowed to request a ride. You will configure the application to integrate with [Amazon Cognito](https://aws.amazon.com/cognito/) for these purposes via the [AWS Amplify JavaScript library](https://aws-amplify.github.io/).
@@ -15,13 +15,13 @@ For this module, we will be creating a Cognito User Pool as our secure user dire
1515

1616
## Implementation Overview
1717

18-
Each of the following sections provides an implementation overview and detailed, step-by-step instructions. The overview should provide enough context for you to complete the implementation if you're already familiar with the AWS Management Console or you want to explore the services yourself without following a walkthrough.
18+
Each of the following sections provides an implementation overview and detailed, step-by-step instructions. The overview should provide context for you to complete the implementation yourself if you're comfortable with the AWS Management Console and are comfortable exploring the services and documentation yourself without following a walkthrough.
1919

2020
If you're using the latest version of the Chrome, Firefox, or Safari web browsers the step-by-step instructions won't be visible until you expand the section.
2121

2222
### 1. Running the website locally
2323

24-
1. From your Cloud9 workspace, select the terminal window and when you are within your website directory, run the following command to start the local web server
24+
1. From your Cloud9 workspace, select the terminal window and when you are within your `~/environment/aws-serverless-workshops/Auth/website` directory, run the following command to start the local web server
2525

2626
```console
2727
yarn start
@@ -30,7 +30,7 @@ If you're using the latest version of the Chrome, Firefox, or Safari web browser
3030
Wait for the development server to start. You can ignore any message saying *Compiled with warnings* as we will resolve these warnings as we add our functionality to the application.
3131

3232

33-
2. Now that the development server has started, click **Preview** in the top of the screen next to the Run button.
33+
2. Now that the development server has started, click **Preview Running Application** in the top of the screen next to the Run button.
3434

3535
![Cloud9 Preview](../images/cloud9-local-preview.png)
3636

@@ -44,12 +44,14 @@ If you're using the latest version of the Chrome, Firefox, or Safari web browser
4444

4545
### 2. Creating a Cognito User Pool
4646

47-
Amazon Cognito lets you add user sign-up, sign-in, and access control to your web and mobile apps quickly and easily. In this step, we'll create a Cognito user pool for use with our Wild Rydes app.
47+
Amazon Cognito lets you add user sign-up, sign-in, and access control to your web and mobile apps quickly and easily. In this step, we'll create a Cognito user pool for our Wild Rydes app.
4848

4949
#### High-Level Instructions
5050

5151
Use the AWS console to create an Amazon Cognito User Pool requiring e-mail verification.
5252

53+
**Note**: The console's region will default to the last region you were using previously. Change this to the same region where you launched your CloudFormation pre-requisite stack.
54+
5355
<details>
5456
<summary><strong>Step-by-step instructions (expand for details)</strong></summary><p>
5557

@@ -67,23 +69,23 @@ Use the AWS console to create an Amazon Cognito User Pool requiring e-mail verif
6769

6870
![User Pool Setup Step 1](../images/cognito-userpool-setup-step1.png)
6971

70-
7. Leave **Username** selected, but additionally select *Also allow sign in with verified email address* and *Also allow sign in with verified phone number*.
72+
7. Leave **Username** selected, but additionally select **Also allow sign in with verified email address** and **Also allow sign in with verified phone number**.
7173

7274
8. Leave all other attribute defaults as-is.
7375

74-
9. Choose **Next**.
76+
9. Choose **Next step**.
7577

7678
![User Pool Setup Step 2](../images/cognito-userpool-setup-step2.png)
7779

78-
10. Leave password policies and user sign up settings set to default settings and choose **Next**.
80+
10. Leave password policies and user sign up settings set to default settings and choose **Next step**.
7981

8082
![User Pool Setup Step 3](../images/cognito-userpool-setup-step3.png)
8183

82-
11. Leave MFA set to Off for this workshop.
84+
11. Leave **MFA set to Off** for this workshop.
8385

8486
12. Leave the default setting selected of requiring e-mail verification.
8587

86-
13. Choose **Save changes**.
88+
13. Choose **Next step**.
8789

8890
![User Pool Setup Step 4](../images/cognito-userpool-setup-step4.png)
8991

@@ -95,7 +97,7 @@ Use the AWS console to create an Amazon Cognito User Pool requiring e-mail verif
9597

9698
![User Pool Setup Step 5](../images/cognito-userpool-setup-step5.png)
9799

98-
17. Choose **Add an app client**.
100+
17. In the next screen, click the **Add an app client** link.
99101

100102
18. Input `wildrydes-web-app` as the app client name.
101103

@@ -113,21 +115,27 @@ Use the AWS console to create an Amazon Cognito User Pool requiring e-mail verif
113115

114116
24. Review summary of all provided settings for accuracy then choose **Create pool**.
115117

118+
![User Pool Setup Step 7](../images/cognito-userpool-setup-step7.png)
119+
116120
25. Within Cloud9, click the **+** symbol and choose to create **New File**. You will use this new blank editor tab as a scratchpad for various resource names and variables.
117121

118122
![Cloud9 Create Scratchpad Tab](../images/cloud9-createscratchpadtab.png)
119123

120124
26. Back in the AWS Cognito console, copy your new **User Pool Id** into the scratchpad tab.
121125

126+
![Copy User Pool ID](../images/cognito-userpool-copy-userpool-id.png)
127+
122128
27. Choose **App clients** heading under **General settings** within the Cognito navigation panel.
123129

124130
28. Copy the **App client ID** over to your scrathpad. You will be using both of these values later on.
125131

132+
![Copy User Pool App Client ID](../images/cognito-userpool-copy-appclient-id.png)
133+
126134
</p></details>
127135

128136
### 3. Creating a Cognito Identity Pool
129137

130-
Cognito Identity Pools are used to provide AWS credentials via IAM roles to end-user applications. Since we'll be using IAM integration to integrate our Cognito deployment and users with other AWS services, we'll go ahead and create this identity pool now.
138+
Cognito Identity Pools are used to provide AWS credentials via IAM roles to end-user applications. Since we'll be integrating our Cognito deployment and users with other AWS services, we'll go ahead and create this identity pool now.
131139

132140
#### High-Level Instructions
133141

@@ -142,7 +150,9 @@ You will need to create a Cognito Identity Pool linked to the Cognito User Pool
142150

143151
1. Input `wildrydes_identity_pool` as the Identity pool name.
144152

145-
1. Under Authentication providers, within the Cognito tab, input the User Pool ID and App client Id you copied previously to the scratchpad tab.
153+
1. Expand Authentication providers.
154+
155+
1. Within the Cognito tab, input the User Pool ID and App client Id you copied previously to the scratchpad tab.
146156

147157
![Identity Pool Setup Step 1](../images/cognito-identitypool-setup-step1.png)
148158

@@ -162,12 +172,14 @@ Now that you've created and configured your Cognito User Pool and Identity Pool,
162172

163173
#### High-Level Instructions
164174

165-
You will import the AWS Amplify library into the project then add sign-up and sign-in utility classes to integrate with our existing UI and front-end components.
175+
You will import the [AWS Amplify](https://aws-amplify.github.io/) JavaScript library into the project then add sign-up and sign-in utility classes to integrate with our existing UI and front-end components.
176+
177+
You'll need to complete the implementation of the onSubmitForm and onSubmitVerification methods within the /Auth/website/src/auth/signIn.js file, as well as the methods of the same name within the /Auth/website/src/auth/signIn.js file. Finally, you'll need to complete the implementation of a method to check whether the user is authenticated within the /Auth/website/src/index.js page.
166178

167179
<details>
168180
<summary><strong>Step-by-step instructions (expand for details)</strong></summary><p>
169181

170-
1. Before using any AWS Amplify modules, we first need to configure Amplify to use our newly created Cognito resources by updating `/website/src/amplify-config.js`.
182+
1. Before using any AWS Amplify modules, we first need to configure Amplify to use our newly created Cognito resources by updating `/Auth/website/src/amplify-config.js`.
171183

172184
1. After opening this file in your Cloud9 IDE editor, find an replace the following parameters with values from your previous scratchpad:
173185
- `identityPoolId`
@@ -191,8 +203,10 @@ You will import the AWS Amplify library into the project then add sign-up and si
191203
```
192204
const isAuthenticated = () => Amplify.Auth.user !== null;
193205
```
206+
207+
1. **Save your changes** to the `/website/src/index.js` file.
194208

195-
1. Now that we've imported the Amplify and configured the Amplify library, we need to update our application's code to sign-up users using Amplify and Cognito User Pools by finding and replacing the following methods within the `/website/src/auth/SignUp.js` file with the code below then save your changes.
209+
1. Now that we've imported the Amplify and configured the Amplify library, we need to update our application's code to sign-up users using Amplify and Cognito User Pools by finding and replacing the following methods within the `/website/src/auth/SignUp.js` file with the code below **then save your changes**.
196210

197211
```
198212
async onSubmitForm(e) {
@@ -240,7 +254,7 @@ You will import the AWS Amplify library into the project then add sign-up and si
240254
}
241255
```
242256

243-
1. You additionally need to integrate the sign-in capability to use AWS Amplify and Cognito by finding and replacing the following methods within the `/website/src/auth/SignIn.js` file with the code below then save your changes.
257+
1. You additionally need to integrate the sign-in capability to use AWS Amplify and Cognito by finding and replacing the following methods within the `/website/src/auth/SignIn.js` file with the code below **then save your changes**.
244258

245259
```
246260
async onSubmitForm(e) {
@@ -275,7 +289,7 @@ You will import the AWS Amplify library into the project then add sign-up and si
275289
const data = await Auth.confirmSignIn(
276290
this.state.userObject,
277291
this.state.code
278-
);
292+
);
279293
console.log('Cognito User Data:', data);
280294
const session = await Auth.currentSession();
281295
// console.log('Cognito User Access Token:', session.getAccessToken().getJwtToken());
@@ -300,7 +314,9 @@ Now that you have integrated our Amplify code into our application, you need to
300314

301315
Return to your browser tab where you started your Wild Rydes application earlier after popping out from the Cloud9 IDE once in preview mode. This page automatically refreshes after you save any code changes so should now reflect all of your changes and be ready for testing.
302316

303-
Sign-up as a new user then sign-in with that user. Provide a valid phone number with `+country_code` first preceeding the number. For a US-based phone number, an example would be `+14251234567`. You should then see that a verification message is sent with a one-time code upon registering, which is required before you're able to sign-in.
317+
Visit the /register path to sign-up as a new user, providing a valid phone number with `+country_code` first preceeding the number. For a US-based phone number, an example would be `+14251234567`. You should then see that a verification message is sent with a one-time code upon registering, which is required before you're able to sign-in.
318+
319+
After signing up as a new user, sign-in with the same user. If the page loads a map, sign-in was successful and you have successfully integrated Cognito for app authentication.
304320

305321
<details>
306322
<summary><strong>Step-by-step instructions (expand for details)</strong></summary><p>
@@ -313,11 +329,15 @@ Sign-up as a new user then sign-in with that user. Provide a valid phone number
313329

314330
1. On the verify e-mail screen, enter the one-time code sent to your e-mail address provided then choose **Verify**.
315331

332+
**Note**: Be sure to check your spam folder for the e-mail with your verification code if you do not see it in your inbox.
333+
316334
1. Assuming no errors were encountered, you will be redirected to the Sign-in screen. Now, re-enter the same e-mail address and password you chose at registration.
317335

318336
1. **If prompted for an MFA code**, check your phone entered previously for an SMS message. Enter your **SMS MFA code** at the verification code prompt then choose **Verify**. If not prompted for an MFA code, skip this step.
319337

320-
1. If the page then loads a map, sign-in was successful and you have successfully integrated Cognito for app authentication.
338+
1. If the page then loads a map, sign-in was successful and you have successfully integrated Cognito for app authentication.
339+
340+
1. Optionally, you may scroll down beyond the map to copy your user's identity token and decode it by pasting it into the 'encoded' input box at [JWT.io](http://jwt.io). You will see all of your user's attributes are encoded within the token, along with other standard attributes such as the time the token was issued, the time the token expires, the user's unique ID, and more.
321341

322342
</p></details>
323343

0 commit comments

Comments
 (0)