Auth0 NodeJS proof of concept
-
Sign up for a free account at Auth0
-
Create a new server application (NodeJS/Express)
-
Callback URL: http://localhost:3000 (default)
-
Create a new local cert =
localhost-key.pem
with a key =localhost.pem
:brew install mkcert nss mkcert -install mkcert localhost
-
Add dependencies
yarn init yarn add express [email protected]
-
Added source code from Auth0 quickstart.
-
Added a script to run Node easily.
-
Created a test user in my Auth0 account and confirmed via email.
Prerequisites: node, yarn, mkcert, nss, an Auth0 account.
-
Make certificates
-
Create an Auth0 account
-
Create a
.env
file:APP_SESSION_SECRET=<secret> CLIENT_ID=<client id> ISSUER_BASE_URL=<base url>
-
Run yarn:
yarn install yarn start
-
Visit localhost:3000
No cookies, displays "logged out"
-
Visit /login
Redirected to ISSUER_BASE_URL with URL parameters state, client, protocol, scope, response_type, redirect_uri, nonce, response_mode Cookies: _csrf, auth0_compat, auth0 (session cookie), did_compat, did (device ID)
-
Log in with valid credentials:
Redirected back to `baseURL` Cookies: `identity`
yarn libyear
: run the libyear command to determine dependency ageyarn lint
: run eslint to report on code issuesyarn start
: run the serveryarn start:dev
: run the server in dev mode undernodemon
for hot reloads