This is a template for adding authentication in NodeJS using passport with sessions.
It stores sessions in MongoDB database using MongoStore.
The server.js has also necessary security implementations.
MONGODB_URI This is the connection address into your database.
SALT_ROUNDS This will set how many times the password will be salted
PASSPORT_SECRET A signature consists of random character string that is appended to the sessionID
If you want to add Google Authentication you can add the following variables:
GOOGLE_CLIENT_ID
GOOGLE_CLIENT_SECRET
- Clone the repository in your local
https://github.com/erxon/passport-auth-nodejs.git - Run
npm ito install all the necessary packages - Set the necessary environment variables:
MONGODB_URI,SALT_ROUNDS, andPASSPORT_SECRET - Execute
npm run startin your terminal - That's it and enjoy