Node Express Passport Example
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Node Express and Passport test bed

Local Authentication

I have used this to test various configurations for using the Passport module for local authentication of Usernane and Password.

I am not a Node expert, hence why I created this test bed to try to understand how it works better, hopefully it will be of use to others.

I generally run a browser and a shell session side by side so that I can see the output from node at the same time as I use the app.

I have put loads of console.log lines in, its ip to you to add or remove these and implement a properlogging module is you want.

It Allows for:

  • Testing HTTP and HTTPS (see below about certificates)
  • Login of existing users
  • Logout
  • Registration of new users
    • currently set to not automatically log new users in


To install and run, download this to a folder of your choice then run:

npm install
cd certs
cd ..
npm start

You can then browse using http or https on the ports set (defailt 3000 and 3443).

Note that within the application you can switch between http and https using the buttons provided.


There are some default users and password set, checkout the my-modules/db.js. You can of course register your own users.


You need to add some keys into the certs folder, it currently expects the files cert.pem and keys.pem. There is a script to generate self signed certificates.


In this example I store uid, username and passord in a Javascript object that allows me to look up by name and also by uid.

The data is not persisted so is lost as soon as you stop the app, and is recreated from scratch when you run the app again.