Authentication with JWT, Dependency Mocking, & Data Validation
Start dependencies with docker-compose up -d
Start server with make run
Example for creating a new account:
POST /v1/public/account/register HTTP/2
Host: localhost:5000
user-agent: insomnia/2021.4.1
content-type: application/json
accept: */*
{
"username" : " Peter" ,
"password" : " mypsw123456"
}
POST /v1/public/account/login HTTP/2
Host: localhost:5000
user-agent: insomnia/2021.4.1
content-type: application/json
accept: */*
content-length: 52
{
"username" : " Peter" ,
"password" : " mypsw123456"
}
Use the token to access a protected resource:
GET /v1/api/secret HTTP/2
Host: localhost:5000
user-agent: insomnia/2021.4.1
authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2Mjc0NjA0MjQsImlkIjoiNjEwMTBmYjk5ZWFhM2Y1NjRmMjU2MDRmIn0.WaRyekr5knEtIVTFPmObYqz1lLhpX5dvjqT8f4UWsZU
content-type: application/json
accept: */*
content-length: 0
External packages used in the development of this project:
Echo - High performance, extensible, minimalist Go web framework
Viper - Handle configuration needs and formats