Skip to content

Latest commit

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

token

TXN2 JWT token middleware for gin-gonic.

gin-gonic Implementation

Includes:

import (
"github.com/gin-gonic/gin""github.com/txn2/token"
)

Add token middleware:

// gin routerr:=gin.New()
// token middlewarejwt:=token.NewJwt(token.JwtCfg{
Exp: 10, // minutesEncKey: []byte("DZCAJZGByGb7pGc3zJKdQ9wGYKRDZpZETZN46tzTWFT"),
})
r.Use(jwt.GinHandler())

Example

Run Source:

go run ./example/server.go --key="n2r5u8x/A?D(G+KbPdX"

Tokenize a JSON object:

TOKEN=$(curl -X POST http://localhost:8080/tokenize?raw=true -d '{ "id": "sysop", "description": "Global system operator", "display_name": "System Operator", "active": true, "sysop": true, "password": "REDACTED", "sections_all": false, "sections": [], "accounts": [], "admin_accounts": []}')&&echo$TOKEN

Validate the token:

curl http://localhost:8080/validate -H "Authorization: Bearer $TOKEN"

About

WIP: TXN2 JWT user token

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages