Skip to content

My little test for authorized requests to a nodejs server using nodejs, json web tokens, and mongodb.

Notifications You must be signed in to change notification settings

rinzler100/nodejs-mongo-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NodeJS Mongo Auth

My little test for authorized requests to a nodejs server using nodejs, json web tokens, and mongodb.

Todo:

  • Additional frontend pages, such as a user management page.
  • Add a way to delete a users' account.
  • Add a way to change a users' password.
  • Token refresh on session verify?

  • Signup
  • Login
  • Verify session
  • Test authorized endpoint
  • Encrypt passwords before storing in MongoDB
  • Add roles to users.
  • Owner role that can assign roles to users via username and manage users.

Quick Start Guide

Install NodeJS

Node Version Manager (NVM) is one of the easiest ways to install node and keep it up to date.

  • You can install it using curl or wget.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash
  • Source the new instructions NVM added to .bashrc during the installation process. You can either exit and re-enter the shell console, or manually source your .bashrc file. This file is almost always located at the root of your home directory.
source ~/.bashrc
  • Check to see if it installed successfully
nvm --version

Now to install NodeJS we simply run the command:

nvm install --lts

Setting Up the Server

Now on to setting up the actual server.

git clone https://github.com/rinzler100/nodejs-mongo-auth
cd nodejs-mongo-auth/server
npm install
  • Next, use the config.json.example to format your config.json file.
node index.js
  • And you're done! Use node index.js & to run the process in the background.

MongoDB Setup

The easiest way to use MongoDB is to use Mongo Cloud's Atlas servers (which have a free version).

  • Go to cloud.mongodb.com to get started.
  • Make a free organization
  • Make a free project then add a free database (cluster)
  • Add a user in the Database Access section and copy the username and password for use in the NodeJS server (in the .env file).

Setting Up the Client

The client is just a singular HTML file, you can download it and open it in any modern browser.

--> You will need to modify the file if you are running the server on anything other than http://localhost:3000

About

My little test for authorized requests to a nodejs server using nodejs, json web tokens, and mongodb.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published