Giter Site home page Giter Site logo

cognito-phx's Introduction

CognitoPhx

Integrating Cognito and Phoenix 1.3, using AWS clients, for Elixir

The following functionality is covered;

  • User registration
  • Confirm registration (with the confirmation code received from AWS, by email)
  • User login
  • Accessing a secured page if logged in
  • Resetting a forgotten password (not yet, sorry)
  • Logout

Integration is a tad tricky, given the verbosity of the API. Below is a simplified sequence diagram illustrating the user registration

Build, start

Pull the project from Gitlab

$ git clone [email protected]:azohra/cognito-phx.git
$ cd cognito-phx

Set up AWS Cognito with the correct configuration

First we will set up a new AWS Cognito user pool with the correct configuration.

  1. Visit your AWS console and go to the AWS Cognito service. Click on "Manage your User Pools" and click "Create a User Pool".
  2. Specify a name for your pool and click "Review Defaults".
  3. Optional: edit the password policy to remove some of the requirements. If you are just testing, using simple passwords will make it easier.
  4. Click the "edit client" link. Specify a name for your app and be sure to disable the client secret and enable the ADMIN_NO_SRP_AUTH option.
  5. Click "Create pool". Take note of the Pool Id at the top of the page and click on the apps page. Here, take note of the App client id.

For this demo to run, you also must define some local system variables:

export AWS_ACCESS_KEY_ID="xxx"
export AWS_SECRET_ACCESS_KEY="xxxx"
export AWS_REGION="xxxxxx"
export AWS_AZOHRA_CLIENT_ID="xxx"
export AWS_AZOHRA_USER_POOL_ID="xxxx"

Now you can start the Phoenix app.

To start your Phoenix server:

  • Install dependencies with mix deps.get
  • Install Node.js dependencies with cd assets && npm install
  • Start Phoenix endpoint with mix phx.server

Now you can visit localhost:4000 from your browser.

HTH!
Florin

Learn more

cognito-phx's People

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.