Skip to content

theanuragshukla/auth-microservice

Repository files navigation


Logo

Auth-ms

Production ready, gRPC enabled, Auth microservice

Explore the docs »

View Demo . Report Bug . Request Feature

Downloads Contributors Forks Stargazers Issues License

Table Of Contents

About The Project

An Authentication microservice written in Go. Auth is a vital part in most of the real world Products/Services. Almost every project on open internet need authentication. So, I built this microservice so that, Instead of implementing Auth from scratch in each of my projects, I can spin up an Auth-ms instance and focus on other important features of my project.

Why this is better:

  • Your time should be focused on creating something amazing. A project that solves a problem and helps others
  • You shouldn't be doing the same tasks over and over like implementing Auth from scratch in every project
  • You should element DRY principles to the rest of your life 😄
  • Most of the other libraries have the following shortcomings:
    • Way too complex to be integrated in a simple project (maybe a college project)
    • Not Production Ready
    • Need to be deeply nested in project source code

Of course, This might not be suited for much more sophisticated Auth requirements, but it is sufficient enough to be used in majority of the projects I've created during my college years.

Built With

  • Golang
  • Zap
  • gRPC
  • Gorilla MUX
  • GORM
  • Viper
  • Go standerd libraries

Getting Started

There are several ways to get started

  • Deploy a prebuilt docker container
  • Build and run locally
    • Docker compose
    • Standalone installation

Prerequisites

For Docker:

  • PostgreSQL
  • Docker

For Docker Compose:

  • Docker
  • Docker Compose

For StandAlone Service:

  • Golang
  • PostgreSQL

Installation

Step 1: Fullfill the prerequisites

Step 2: Depending upon the type of installation you want, It may vary:

Using Docker:

  • Start your Postgres Server and Create a Database
  • In the Project root, rename the .env.example to .env and Fill all the DB info like host, port, etc.
  • Build the Project using Docker
docker build -t auth .
  • Run docker Container
docker run auth

Using Docker Compose:

  • Run the container using docker-compose
docker-compose up -d

As Standalone Service

  • download all the dependencies
go mod download
  • Run the Service:
go run main.go

NOTE: While using the Docker/Docker-compose methods, Instead of building locally, You can also fetch a prebuilt container using the following command

docker pull ghcr.io/theanuragshukla/auth-microservice:sha256-3f2a36a9358dcf2c38881ed2ab01afcd5ee7f695de9fb5b2c6e23590a4b81bd6.sig

Features

  • Provides basic Authentication:
    • Access and Refresh tokens
    • UID
  • Fully Integrated Logging, for easy debugging in case of any failure
  • Live monitoring using Log files
  • gRPC endpoints for integration with other services
  • REST endpoints for client side applications
  • Automatically DB Managements using GORM

Documentation

TODO

Authors

  • Anurag Shukla - Comp Sci Student - Anurag Shukla - built Auth-ms