Description
AWS Coginto is a user mangement tool for web and mobile applications. This project is a basic setup to get familiar with Cognito and the interface. It is meant to run for testing on localhost (or even file://) as passwords are sent in plaintext. Shoutout to Robert for help in getting me started and sharing his html code.
Tools Used in this Project
- Amazon Coginto
- My Github Project - smylee_basic_cognito
Coginto Setup
Note: Cognito is still in beta and at times the setup form can be a little flakey. Some values won’t save even though it seems like it would. I will try to write this to minimize those distractions.
Create a User Pool
-
Choose your region. Coginto is only avaliable in eu-west-1 (Ireland), ap-northeast-1 (Tokyo), and us-east-1 (N. Virginia).
-
Create a User Pool.
-
Enter a Name, then choose “Step through settings”
-
Choose email, name, phone, preferred username. Add a custom attribute of string, name “city”. BUT WAIT! This is one of the pages with a bug. When you try to continue (next step), it will not do anything. To “fix” this, mark the checkbox for preferred name > alias, uncheck, then go to next step.
-
Password strength is completely up to you. Next step.
-
Leave MFA off, and mark the checkbox Phone Number. Change the text in the textboxes if desired. Next step. According to the docs “If a user signs up with both a phone number and an email address, and both are selected for verification, the code is sent via SMS to the phone.” Texting charges to your phone will apply depending on your plan. Keep unchecked if desired.
-
Add an app, enter a name, and uncheck Generate Client Secret. Create App. Copy App Client ID, you will need it later. Next Step.
-
Skip the triggers sections. Next step.
-
Your User Pool is created! Copy the Pool ID, you will need it later.
Create Federated Identities
-
Create new identity pool.
-
Add Identity pool name. Enable access to unauthenticated identities.
-
Add Authenitcation Providers > Coginto. Paste the User Pool ID and App Client ID copied from earlier.
-
Create Pool.
-
The IAM users page will appear. Keep the default settings and Allow.
-
Edit the newly created Identity Pool, and copy the Identity Pool Id for later.
EDIT THE INDEX
- Download or clone the data from: https://github.com/smyleeface/smylee_basic_cognito
- Edit the index.html file and replace with your settings and copied data from earlier.
- REGION
- IDENTITY_POOL_ID
- USER_POOL_ID
- CLIENT_ID
- Open the index.html file in a browser.
TRY IT!
-
Create a new user.
-
Verify user with code from email or text.
-
Login as user.
-
Logout as user.
-
View user in Cognito.
Extend
- Try adding a delete or other use cases to this. Lots of examples on the AWS Coginto Identity JS Github
Footnotes
- Phone number verification is only setup for US numbers in this sample code.
AWS Costs for creating this project
- AWS provides a lot of services for free for the first 12 months of sign up and beyond. More information can be found on AWS pricing pages.
- Should be no cost to create this project, but if you did go over limits, should cost no more than $2.
- AWS Cognito - You pay based on your monthly active users (MAUs). This means if a user is inactive for the entire month, they will not be charged towards your count of MAUs. First 50,000 MAUs are free.
- AWS SNS - Each month, Amazon SNS customers receive 1,000,000 Amazon SNS Requests, 100,000 HTTP notifications, 1,000 email notifications and 100 SMS notifications for free. Per monthly calculator
Resources
- AWS Coginto Identity JS Github
- Robert’s Brain ;) … and files