emmanuelmillionaer / aws-cognito-js-login

Example app showing correct set up and usage of amazon-cognito-identity for js
MIT License
36 stars 21 forks source link

aws-cognito-js-login

Shows correct set up and usage of https://github.com/aws/amazon-cognito-identity-js in a Demo Application. The Application allows a user to sign-up with different User-Atrributes. It can be used with MFA settings enabled.

Setup

First step: Clone this project and download the following Libraries to a folder named /dist:

  1. /dist/aws-cognito-sdk.min.js
  2. /dist/amazon-cognito-identity.min.js
  3. JavaScript BN library
  4. Stanford JavaScript Crypto Library

For more information about the dependencies click here


Second step: Go to the AWS Cognito User Pools and create a new User Pool: For the settings used in this application enable MFA and choose next to email as required attribute phone number.

When creating the Client app it's IMPORTANT to uncheck the generate client secret box. Because the JavaScript SDK doesn't support apps that have a client secret.


Third step: Go to AWS Cognito Federated Identites and create a new Identity Pool for your User Pool.

For your Identity Pool you can create a Authenticated role as well as a Unauthenticated role, where you can define what your users are allowed to do. For example reading from/uploading to S3.


Forth step: After you created all necessary AWS rescources, you need to reference them in your application. For that open the file config.js and edit the variables. The Ids like identityPoolId or UserPoolId you are able to see in the AWS Console.


Great, be your first user Open index.html in your browser and sign up for your client app.

This is what you will get:

Links

Article about Amazon Cognito in the Browser.

Here you can find the docs for Official amazon-cognito-identity-js

The kiwi background pattern can be found here