Code Monkey home page Code Monkey logo

reactspa_auth0_awsapigw_poc's Introduction

Overview

PoC to demonstrate utilizing Auth0 to perfrom Authentication to a Single Page Application (React) as well as send API Calls to a resource (AWS API GW / Lambda / Node.js) which performs authorization via an Access Token (JWT)

Repo Components

  • Infrastructure
    • Terraform to deploy AWS REST based APIGW with JWT Authorization
    • Terraform to deply Auth0 Client and Authorization Server
  • API
    • Simple Node.js running on Lambda to return a json object
  • FrontEnd
    • React SPA to perform authentication (OIDC) and then pull an access token from Auth0 Authorization server to send to the above AWS API GW

Diagram

alt text

How to Setup

  • Dependencies

    • Terraform
    • Node
    • AWS Account
    • Auth0 Developer Account
  • Deploy Infra

    • Ensure you have credentials set
      • For AWS Account
        • export AWS_ACCESS_KEY_ID='Access Key'
        • export AWS_SECRET_ACCESS_KEY='Secret Key'
      • For Auth0 Account
        • Setup a "machine to machine application" and provide all permissions to this Application to allow for TF deployment
        • export AUTH0_DOMAIN='Your Dev Auth0 Domian eg 'dev-nfmgw5fwvgsau2ay.us.auth0.com''
        • export AUTH0_CLIENT_ID='M2M client ID for managing Auth0'
        • export AUTH0_CLIENT_SECRET='M2M client Secret'
    • Init and apply the AWS & Auth0 infrastructure
      cd ./Infra/main
      terrafrom init && terraform apply
      
    • Required TF Outputs for Configuring Front End
      • API GW Base URL
      • Auth0 Client ID
        • Run the following command:
        terraform output Auth0_InfraOutputs
        
  • Deploy Front End

    • cd to Frontend/src/Config and edit globals.js
    • Update all global config vars
        API_BASE_URL = the above output from terrafrom with your deployed AWS API GW (e.g. )
        DOMAIN = Base domain of your Auth0 Application (e.g. 'dev-nfmgw5fwvjeau2ay.us.auth0.com')
        CLIENTID = Client ID of your Auth0 Application (e.g. 'b3XxmjcJM1ZYM1S5I0W2CUGAg93IvgSM')
        AUDIANCE =  Audiance value of your Auth0 Application (e.g. 'http://blah.com')
        SCOPE = Set scopes for OIDC and any custom "Permissions" of you Auth0 API (e.g. 'openid profile email read:info')
    
    cd ./Frontend && npm install
    npm run start
    

reactspa_auth0_awsapigw_poc's People

Contributors

chiefriver avatar

Watchers

 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.