This application is intended to be a bootstrap or proof of concept for designing a containerized authentication microservice. The server is easy to run and configure, and currently supports user registration, login, sessions, password recovery and JWT.
- Clone this repo to your local machine using
https://github.com/DanielMil/Authentication-Server
Create a .env file for your configurations in the root directory. Copy the following configuration and edit appropriately.
# MongoDB connection
MONGO_URI = mongodb://mongo:27017/<database>
# When running locally.
# MONGO_URI = mongodb://localhost:27017/<database>
# Email credentials for forgotten password email reset
EMAIL_ADDRESS = <email>
EMAIL_PASSWORD = <password>
# Secrets for JWT and Express-Session.
# Secrets should be a random, private string.
JWT_SECRET = <secret>
SESSION_SECRET = <secret>docker-compose up --buildEnsure that TypeScript, Node.js, tsc and MongoDB are installed on your machine.
npm installtscnpm startnpm run dev # Runs server with nodemonPOST /auth/registerPOST /auth/loginGET /auth/userPUT /auth/userDELETE /auth/userPOST /auth/logoutPOST /auth/password/forgotPasswordPOST /auth/password/resetPassword/:resetPasswordToken- Endpoints to login, register, logout and get current user in session.
- Containerized and exposed with Docker.
- Support user sessions with cookies.
- JWT Support.
- Endpoints for updating user, deleting user and forgotten passwords.
- Change username field to email
- Refactor all code to use async-await