GF jwt plugin
This plugin is forked https://github.com/appleboy/gin-jwt plugin, modified to https://github.com/gogf/gf plugin.
Download and install
$ go get github.com/gogf/gf-jwt
Import
import "github.com/gogf/gf-jwt"
Check demo example/auth/auth.go and use ExtractClaims
to customize user data.
Run example/server/server.go
on the 8000
port.
$ go run example/server/server.go
Test the effect on the command line via httpie.
$ http -v --form POST localhost:8000/login username=admin password=admin
Command line output
$ http -v -f GET localhost:8000/user/refresh_token "Authorization:Bearer xxxxxxxxx" "Content-Type: application/json"
Command line output
We test the return of the hello interface with the username admin
and password admin
$ http -f GET localhost:8000/user/hello "Authorization:Bearer xxxxxxxxx" "Content-Type: application/json"
Command line output
We use an unauthorized token to test the return of the hello interface.
$ http -f GET localhost:8000/user/hello "Authorization:Bearer xxxxxxxxx" "Content-Type: application/json"
Command line output
Thanks again https://github.com/appleboy/gin-jwt