Giter Club home page Giter Club logo

amazon-cognito-react-amplify's Introduction

Blog Post

๐Ÿ“œ See this blog post for more details about this project.

Description

This GitHub project shows how to secure Amazon API Gateway with Amazon Cognito and access it from React application using AWS Amplify.

The backend is provisioned using AWS SAM and consists of:

  • An Amazon API Gateway that acts as a proxy to a serverless function.
  • A Node.js based AWS Lambda function that performs basic CRUD operations on Amazon DynamoDB using AWS SDK.
  • An Amazon DynamoDB table.
  • Resources to setup Amazon Cognito
    • User Pool
    • App Client
    • Domain
    • Identity Pool
    • Roles
    • Groups
    • Users

The React based frontend application uses AWS Amplify for user authentication and communication with Amazon API Gateway. A few additional libraries (Material-UI, react-json-view, react-loading-overlay) are used to improve user experience.

Setup

  • Install Docker.
  • Clone the repo.
  • If your AWS security credentials are not in ~/.aws, then adjust the bind mapping in docker-compose.yml.
  • Rename .env.local to .env.
  • Update S3_BUCKET variable in the .env file with your s3 bucket name. AWS SAM needs it to upload the template and serverless function code.
  • To deploy the backend to AWS run:
docker compose up backend
  • To get configuration data run:
docker compose up describe
  • Copy the above command output into corresponding variables in the .env file.
  • Create demo users password
docker compose run -e USR_PWD=<pwd> --rm users

Demo

  • To start the frontend application run:
docker compose up frontend
  • Open the app http://localhost:3000
  • Verify that you can not perform CRUD operations.
  • Sign in with [email protected] user and password you specified earlier. Verify that you can perform all CRUD operations.
  • Sign out and sign in back with [email protected] (same password). Verify that you can do Get and Scan only. You should get AccessDeniedException if you try to Put, Update or Delete.

Cleanup

  • To delete the backend from AWS run:
docker compose up clean
docker compose down

amazon-cognito-react-amplify's People

Contributors

jvdevlab avatar dependabot[bot] avatar

Stargazers

Timour M avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.