Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Shurtu-gal/auth0-integration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auth0 integration

This is a sample project to test Auth0 integration with NestJS for creation of a plugin.

Installation

$ npm install

Running the app

Follow the instructions in the individual README.md files in the Admin-UI and Server folders.

Prerequisites

Elaboration

Create an Auth0 application

Create an Auth0 API

  • Go to the dashboard and create a new API of type Machine to Machine

  • Set the following values :-

  • Update the Environment Variables in the server project with the values of the Auth0 API created :-

    AUTH0_AUDIENCE = YOUR_AUTH0_API_IDENTIFIER; // https://sample-nest.demo.com
    AUTH0_ISSUER = YOUR_AUTH0_DOMAIN; // Look at quickstart for the format

Create an Auth0 action

  • Go to the dashboard and create a new action of type Post Login through Flows tab ----> Login -----> Create Action

  • Set the following values :-

    • Name : Add user details to access token

    • Code :-

      exports.onExecutePostLogin = async (event, api) => {
        if (event.authorization) {
          // Set claims
          api.accessToken.setCustomClaim("user", event.user);
        }
      };
  • Save and deploy the action

  • Put the action in the Login flow by going to Flows tab ----> Login -----> Select the action from the dropdown and put it between Login and Token issued. Action formation

Create an admin user in the postgres database

  • Go to CustomSeed and add user details as follows :-

    const user = {
      name: "YOUR_NAME",
      email: "YOUR_EMAIL",
      roles: ["user"], // TODO: Add a default role
      username: "YOUR_USERNAME"
      age: 0,
      birthDate: new Date(),
      score: 0,
      interests: [],
      priority: "low",
      isCurious: false,
      location: "(32.085300, 34.781769)",
      bio: "YOUR BIO",
      extendedProperties: {},
    };
  • Then run the following command to seed the database :-

    $ npm run seed
  • The user can now login with the email in Auth0.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages