Giter VIP home page Giter VIP logo

auth-microservice's Introduction

Overview

Authentication microservice built with C# and ASP.NET Core. Docker containers and Docker Compose fully supported.

Schema auth-microservice

Features

  • JWT access tokens
  • User database
  • Role-based access control
  • gRPC services and REST API
  • CLI tool

Database

PostgreSQL user database. Users are managed with .NET Entity Framework and Identity system.

These provide production-ready user and database management that can be extended.

Passwords

BCrypt hashing algorithm with pepper. Pepper is a secret value that is added to passwords before passing them to BCrypt. It provides an additional layer of security.

Environment

Name Default value
ConnectionStrings__UserDatabase Host=localhost;Port=12345;Database=userdb;Username=userdb_user;Password=userdb_pass
AppConfig__PasswordPepper YourSecretPepper
AppConfig__AdminUsername admin
AppConfig__AdminPassword Admin10!
AppConfig__NormalUserUsername user1
AppConfig__NormalUserPassword Pass10!
JwtConfig__Issuer issuer.example.com
JwtConfig__Audience audience.example.com
JwtConfig__SigningKey Your Signing key.

CLI

Name Default value
GRPC_API_URL http://localhost:5106
REST_API_URL http://localhost:5105/api/v1

Health checks

/health/summary - Gives service health summary including database status. This endpoint is only available in port 5105. gRPC port 5106 does not have this.

REST API

POST /api/v1/auth/login - Login with username and password

GET /api/v1/users - Get all users. Authentication and admin role required.

CLI

CLI tool is built with Rust. You need Rust tools to build it.

You can install Rust here: https://www.rust-lang.org/tools/install

Start by setting environment variables in your shell process.

GRPC_API_URL=http://localhost:5106
REST_API_URL=http://localhost:5105/api/v1

If you are using PowerShell

$Env:GRPC_API_URL="http://localhost:5106"
$Env:REST_API_URL="http://localhost:5105/api/v1"

Build the binary

cargo build

Or build more optimized release version

cargo build --release

Login can be done using both gRPC and REST. Login returns JWT access token and it gets saved to a file. After login, you can list all users (Admin role required.).

auth-cli --help

Login using gRPC service

auth-cli login

Login using REST API

auth-cli login --rest

List all users using gRPC service

auth-cli user ls

List all users using REST API

auth-cli user ls --rest

Docker

Go to the project root in terminal

cd auth-microservice

Run PostgreSQL

docker compose -f docker-compose.db.yml up -d

Access it from your localhost's port 12345

Run PostgreSQL and microservice

docker compose up -d

gRPC services port 5106

REST API port 5105

auth-microservice's People

Contributors

hollowdll avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.