This page explains how to add user authentification with Auth0
Auth0 is a cloud-based platform that provides authentication and authorization services for applications. It allows developers to authenticate users using a variety of methods, including social logins (Google, Twitter, Facebook...), single sign-on, and multi-factor authentication. Auth0 also provides tools for managing user profiles and permissions, as well as API security and access control. It is designed to make it easy for developers to add secure authentication and authorization to their applications, without having to build these capabilities from scratch.
The following has been performed with the following versions:
Let's start by creating the Node.js project:
npm init -y
Let's now install the required packages
express
for the Node.js frameworkdotenv
for environment variableexpress-openid-connect
for authentification with Auth0npm install express dotenv express-openid-connect
Create an account on Auth0.
Once your logged, create a new application. Set your application name and select regular Web Application:
Select Node.js app:
Then create a new Node.js project (Explore Sample App):
The next page is the configuration page. Leave the default parameters and click on Save And Download App.
A file name 01-login.zip
should be downloaded/
Unzip the file in your project folder.
[Optional] Note that I use Volta to run any version of Node.js. In my case, I ran:
volta install node@18.13.0
volta install npm@8.19.2
Pin you Node.js and npm version in the project:
volta pin node@18.13.0
volta pin npm@8.19.2
Execute the following commands in the sample's directory:
npm install
npm start
In your favorite browser, go to http://localhost:3000/
:
Log-in, go to your profile page and check your profil information: