PROJECT : AUTHENTICATION BASICS and SECURITY CONFIGURATION using node.js(tutorial)

Creating users and allowing them to log in and out of a web apps is a crucial functionality that I am ready to learn!. In this lesson we’re going to be using passportJs an excellent middleware to handle the user's authentication and sessions.

I am going to be building a very minimal express app that will allow users to sign up, login and log out. For now I am just going to keep everything except the views in one file to make for easier demonstration, but in a real world project, it is best practice to split our concerns and functionality into separate modules.

This project is part of a series of lessons to be completed by developers in The_Odin_Project.

Built With

  • Express.js.
  • PassportJS
  • Npm.
  • ES6.
  • bcrypt.js

Learning Outcomes

PassportJS

  • Understand the use order for the required middleware.
  • Describe what Strategies are.
  • Use the LocalStrategy to authenticate users.
  • Explain the purpose of cookies in authentication.
  • Refreshed on prior learning material (routes, templates, middleware)
  • Use PassportJS to setup user authentication with Express.

Data Security/Safety

  • Describe what bcrypt is and its use.
  • Explain the importance of password hashing.
  • Describe bcrypt’s compare function.

Security Configuration.

  • Access environment variables using the process object in node
  • Use dotenv to store and make environment variables available to the application globally.
  • Describe how environment variables are handled in version control.
  • Work with nconf’s hierarchical configuration

To get a local copy up and running follow these simple example steps.

Prerequisites

  1. Git.
  2. Code editor.
  3. browser.

How to run the program

  1. Open the terminal.

  2. Enter git clone https://github.com/othman-19/authentication-basics-nodejs.

  3. Navigate to the cloned repository.

  4. In the terminal cd into authentication-basics-nodejs.

  5. Run npm install in your terminal.

  6. Run your local server with node app.js.

  7. Open http://localhost:3000 to view it in the browser.

  8. Try subscribe, login and logout.

Author(s)

Othmane Namani.
Email: othmanenaamani@gmail.com.
Portfolio.
LinkedIn.
twitter.
DEV Community.
Angel List.

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check the issues page.

Show your support

Give a ⭐️ if you like this project!