All in one finance authentication API
Overall documentation for the aiof Auth microservice
Authentication can be done via the /auth/token
endpoint. There are several ways an entity can authenticate:
email
andpassword
forUser
api_key
forUser
orClient
refresh_token
forUser
orClient
Request
{
"email": "test@test.com",
"password": "test"
}
Response
{
"token_type": "Bearer",
"expires_in": 900,
"access_token": "jwt_access_token",
"refresh_token": "refresh_token"
}
Request
{
"api_key": "api_key_here"
}
Response
{
"token_type": "Bearer",
"expires_in": 900,
"access_token": "jwt_access_token",
"refresh_token": "refresh_token"
}
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
- Fluent Validation for validation
- IANA JSON Web Token (JWT)
- OpenID Connect Discovery 1.0
- Configure Applications with OpenID Connect Discovery
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
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
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)
From the root project directory
docker-compose up