Skip to content

Authentication with JWT, Dependency Mocking, & Data Validation

Notifications You must be signed in to change notification settings

PeteGabriel/jwt-go-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Authentication with JWT, Dependency Mocking, & Data Validation

Running the project:

  • 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"
}

Get a token after login:

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
61010fb99eaa3f564f25604f

External packages used in the development of this project:

  • Echo - High performance, extensible, minimalist Go web framework
  • Viper - Handle configuration needs and formats

About

Authentication with JWT, Dependency Mocking, & Data Validation

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages