SayidHosseini / authentiq

An "authentique" authentication service, developed with express.js framework, powered by MongoDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Authentiq

license_badge build_status_badge docker_build_badge docker_image_badge docker_pulls_badge

This is a RESTful Authentication Service written in Node.js on express.js framework powered by MongoDB. It is intended that the developer use this as a module (microservice) in a project; rather than a standalone service since it is only a mean of authentication. That being said, if you plan to develop a service that includes authentication, it might be a good idea to have a head start and build on top of this project instead of starting one from scratch.

API Reference is provided in the wiki pages.


ℹ️ A set of environment variables have been introduced to control some configuration and parameters in the application. Feel free to explore them in the .env and docker-compose.yml files. Note that environment variables take precedence over config parameters in config/config.js file. Also, note that you only need to modify the .env file for the cases of docker-compose and docker stack deploy (no need to change the docker-compose.yml file)
⚠️ Authentiq provides JWT for authentication and session management. Currently, we do not generate unique key pairs for each new environment (this feature will be available soon). If you'd like to deploy this project in a production environment, it is very important to generate your own public / private key pair. The generated key pair should be placed in src/jwt/ with the names public.key and private.key.

Setting up As a Service

In order to run this as a service and probably develop on top of it, you'll need to do the followings:

  • Install https://nodejs.org/en/[node.js] and https://www.mongodb.com/[mongoDB].
  • Clone the repository and cd to the cloned repository.
  • Set proper environment variables for your Mongo database (alternatively, you may modify relevant parameters in config/config.json).
  • Optionally, to enable Verify User and Forgot Password capabilities, set proper environment variables.
  • To install dependency packages, run npm install.
  • To run the application for development purposes, run npm run dev or nodemon.
  • To run for production set NODE_ENV to production and run npm start (alternatively, you may use docker-compose; explained later on)
🚩 Running npm start will only run your application; it will not relaunch it in the case that it crashes. To do that, you may use PM2 or Forever or any other package that provides this feature, in order to sustain availability.

Setting up As a Microservice

If you want to run the module as a containerize microservice, you'll need to do the followings:

  • Install Docker.
  • The application is built automatically by DockerHub for the following architectures: x86_64, arm32v6, arm32v7, arm64v8 (aka aarch64) on alpine. Images are available on DockerHub repository and can be pulled with sayid/authentiq. They are tested on normal x86_64 machines as well as RaspberryPi zero w, RaspberryPi 2B, RaspberryPi 3B, RaspberryPi 4B and the ASUS Tinkerboard.
  • If you want to make your own copy of the image, clone it and cd to the cloned repository. Then run docker build -t $DOCKER_ACC/$DOCKER_REPO:$IMG_TAG . to build the image locally. Another option is to fork the repo and enable autobuild on DockerHub.
  • Since there might be other versions in the future and latest would point to those new versions, we recommend that you use version explicit tags (for example alpine-1 tag, which is currently the same as latest) to keep consistency.
  • In order to use this as a microservice in your project, you'll need a MongoDB container with the name authentiq-db. This is the name that should be resolved to the IP address of the MongoDB container. If you'd like to change that, you'll need to modify the proper environment variables.
  • We provide a docker-compose.yml file that includes everything needed to launch the system. You may use either of docker-compose or docker stack deploy to setup the system for production easily! Override the default parameters by setting environment variables in the .env file.
  • If you are planning to use this microservice in a production environment, generate your own key pair, as noted above. Probably, you'll need to create your own image, as well.
  • If you need to store extra information e.g. name or any other user related info, it is advised to store those information in another module (microservice) of your system and keep this container intact and solely for the purpose of authentication and session management.
ℹ️ The Super Admin user of the system is created after the application is started with the following credentials (admin@authentiq.com:admin1234). Override it by setting proper environment variables. Note that the Super Admin user is verified by default!

License

Developed by S. Saeed Hosseini and Mohammad Moradi, released under MIT License.

About

An "authentique" authentication service, developed with express.js framework, powered by MongoDB

License:MIT License


Languages

Language:JavaScript 75.0%Language:Shell 24.0%Language:Dockerfile 1.0%