Image from Unsplash

Handling Authentication and Authorization with Node

Bilguun Batbold
Quick Code
Published in
5 min readMar 18, 2019

--

In this article you will learn about handling Authentication and Authorization for your Node server.

Introduction

Let’s assume you have some routes that provide resources to users. Without proper authentication and authorization, sensitive information can be compromised. Therefore, it is very important to authenticate users and provide different access rights depending on the user type.

What will be used in this tutorial

  • Node.JS
  • Express
  • MongoDB (to store user information)
  • JWT (JSON Web Tokens)
  • Creating simple routes
  • Creating Models / Schema
  • Writing custom authentication middleware
  • VS Code with Powershell as default terminal

Feel free to read my previous articles to get learn more about basics of Node / Express / MongoDB / Mongoose.

JWT

JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.

JWT.IO allows you to decode, verify and generate JWT.

--

--