jwt-test-server

command module
v0.0.0-...-1daab4e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2022 License: MIT Imports: 10 Imported by: 0

README

jwt-test-server

Simple JWT Server made to understand how JWT works.
By https://github.com/mmalessa

Inspired by https://github.com/sohamkamani/jwt-go-example

In a production environment, use it only at your own risk!

Installation

go get github.com/mmalessa/jwt-test-server
go install github.com/mmalessa/jwt-test-server

Run

~/go/bin/jwt-test-server /path/to/config/file.yaml

Configuration

All you need is in config.yaml

jwt:
    key: mySecretKey
    expirationtime: 30 # in minutes
server:
    port: 8000
credentials:
    user1: password1
    user2: password2

API Methods

POST http://localhost:8000/login

Request Body
{
    "username":"myUsername",
    "password":"myHiddenPassword"
}
Response

200: application/json

{
    "token": "eyJhbGciOiJ*********Tw"
}

GET http://localhost:8000/refresh

Header

Authorization: "Bearer eyJhbGciOiJ*********Tw"

Response

200: application/json

{
    "token": "eyJhbGciOiJ*********Tw"
}

GET http://localhost:8000/welcome

Header

Authorization: "Bearer >JWT Token string<

Response

200: application/json

{
    "username": "test",
    "exp": 1561991616
}

Error Responses

400, 401, 500: application/json

{
    "Code": "500",
    "Message": "Internal Server Error"
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL