GJordao / simple-auth

An authentication service that aims to be simple and customisable
MIT License
3 stars 3 forks source link

Simple-Auth

Simple auth aims to be a simple, highly configurable and secure self-hosted service that you can simply deploy and start using.

The minimal setup should be close to plug-and-play.

How to use

You can run the service in two ways:

In both cases you will need a database engine running somewhere

Running locally

Pull the git repo and in a terminal window run the following commands:

Installation

$ npm install

Running the app

$ npm run start:prod

Running with Docker

Ideally we want to have an image in Docker hub, but since we're still developing for now you need to pull the repo and build the image locally.

So firstly pull the repo and open a terminal window on that location.

Then run

docker build -t simple-auth .

Once the image is built you can run the service with the minum config like so:

docker run -p 5000:5000 -e DATABASE_HOST=<YOUR-HOST> -e DATABASE_NAME=<YOUR-DB-NAME> -e DATABASE_PASSWORD=<YOUR-DB-USER-PASSWORD> -e DATABASE_PORT=<YOUR-DATABASE-PORT> -e DATABASE_TYPE=postgres -e DATABASE_USERNAME=<YOUR-DB-USER> -e TOKEN_ENCRYPTION_KEY=<YOUR-ENCRYPTION-KEY> simple-auth:latest

Or if you're using docker-compose add the service to your docker-compose.yml

  auth:
    image: simple-auth:latest
    ports:
      - "5000:5000"
    environment:
      DATABASE_HOST: <YOUR-HOST>
      DATABASE_NAME: <YOUR-DB-NAME>
      DATABASE_USERNAME: <YOUR-DB-USER>
      DATABASE_PASSWORD: <YOUR-DB-USER-PASSWORD>
      DATABASE_PORT: <YOUR-DATABASE-PORT>
      DATABASE_TYPE: postgres
      TOKEN_ENCRYPTION_KEY: <YOUR-ENCRYPTION-KEY>

These are the minimum configurations to run the service. After it is up you should be able to access the available endpoints by accessing localhost:5000

You can access the Open API documentation at: http://localhost:5000/auth/explorer

Configuration

Simple-Auth aims to be highly configurable and this configuration comes in the form of environment variables. Below you will find a list of all the available variables, their description and types.

DATABASE_TYPE *

DATABASE_HOST *

DATABASE_NAME *

DATABASE_PORT *

DATABASE_USERNAME *

DATABASE_PASSWORD *

TOKEN_ENCRYPTION_KEY *

PASSWORD_RESET_URL *

PASSWORD_PEPPER

PORT

ACCESS_TOKEN_EXPIRE_TIME

REFRESH_TOKEN_EXPIRE_TIME

MODE

SMTP_DEBUG

SMTP_HOST

SMTP_PORT

SMTP_SECURE

SMTP_REQUIRE_TLS

SMTP_IGNORE_TLS

SMTP_TLS_CIPHERS

SMTP_USER

SMTP_PASSWORD

SMTP_MAIL_FROM

AUTH_URL

ACCOUNT_CONFIRMATION_REDIRECT_URL

DB_SESSIONS

Development

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov