Built with ExpressJS, this demos a REST API for a Bearer token based authentication system integrated with MongoDB. It uses an npm script to build using Babel so you can write with the latest JavaScript features. The Passport service uses a 'local' username/password strategy, but can be easily modified to use Google, AWS, etc. In addition to the Passport login, this app returns a JWT token that can be saved locally and used when making future requests for secure resources.
- Nodejs - https://nodejs.org/en/download/
- MongoDB - https://docs.mongodb.com/manual/installation/
Simply clone the repo and install dependencies. This will give you
the back-end piece of this full-stack project.
NOTE: The front-end client to this is the Unity project here:
https://github.com/zklinger2000/unity-auth-manager
git clone [email protected]:zklinger2000/express-unity-auth.git
npm install
To keep passwords and keys out of the git repo and somewhat safe, we
use a .env
file that can be read using the dotenv
library.
In the root of the project directory:
touch .env
Now fill in the blanks
PORT=8050
NODE_ENV=development
MONGODB_URI=mongodb://<username>:<password>@<mongo_address>:<mongo_port>/<db_name>
APP_SECRET=someReallyLongString
npm run dev:start
Add additional notes about how to deploy this on a live system
Zachary Klinger
UNLICENSED
Much of this was built upon the techniques learned from Stephen Grider's course on Udemy