Skip to content

Latest commit

 

History

History
149 lines (100 loc) · 3.87 KB

README.md

File metadata and controls

149 lines (100 loc) · 3.87 KB

Overview

All in one finance authentication API

build Build Status

Documentation

Overall documentation for the aiof Auth microservice

Authentication

Authentication can be done via the /auth/token endpoint. There are several ways an entity can authenticate:

  • email and password for User
  • api_key for User or Client
  • refresh_token for User or Client

Example for User

Request

{
    "email": "[email protected]",
    "password": "test"
}

Response

{
    "token_type": "Bearer",
    "expires_in": 900,
    "access_token": "jwt_access_token",
    "refresh_token": "refresh_token"
}

Example for Client

Request

{
    "api_key": "api_key_here"
}

Response

{
    "token_type": "Bearer",
    "expires_in": 900,
    "access_token": "jwt_access_token",
    "refresh_token": "refresh_token"
}

Tests

Unit tests are ran on each pipeline build. The pipelines are built with Azure DevOps from the azure-pipelines.yml file. Additionally, as part of the build pipeline, there are test result coverage reports done by Coverlet. Also, you can click on the build pipeline badge and check the unit test coverage for the latest run

Libraries

JWT

OpenSSL

The service currently uses RSA256 algorithm to sign the JWT's. For this scenario we use OpenSSL to generate a private and public key. In order to do so follow the below steps:

  • Install openssl tools from Chocolatey by running the following command: choco install openssl.light (needs to only be done once)
  • Then restart PowerShell, if required
  • Navigate to a desired directory to create the .pem files
  • Run the command: openssl genrsa -out private-key.pem 2048
  • Run the command: openssl rsa -in private-key.pem -outform PEM -pubout -out public-key.pem

A good article with detailed documentation can be found here. Also, a .pem to XML converter tool can be found here

How to run it

The best and recommended way to run it is using docker-compose. Additionally, below are some quick commands/tips to run it locally.

From the root project directory

dotnet run -p .\aiof.auth.core\

Or change directories and run from the core .csproj

cd .\aiof.auth.core\
dotnet run

Make API calls to

http://localhost:5000

Docker

Pull the latest image from Docker Hub

docker pull gkama/aiof-auth:latest

Or build the local Dockerfile.local

docker build -t aiof-api:latest -f Dockerfile.local .

Run it

docker run -it --rm -e ASPNETCORE_ENVIRONMENT='Development' -p 8001:80 gkama/aiof-auth:latest

Make API calls to

http://localhost:8001/

(Optional) Clean up none images

docker rmi $(docker images -f "dangling=true" -q)

Docker compose

From the root project directory

docker-compose up