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/jinmao88/gf-jwt
Import
import "github.com/jinmao88/gf-jwt"
Run example/main.go
on the 8000
port.
$ go run example/main.go
Test the effect on the command line via httpie or curl.
$ http -v --form POST localhost:8000/login username=admin password=admin
or
$ curl -X POST -d 'username=admin&password=admin' localhost:8000/login
Command line output
$ http -v -f GET localhost:8000/refresh_token "Authorization:Bearer xxxxxxxxx" "Content-Type: application/json"
or
$ curl -H 'Authorization:Bearer xxxxxxxxx' -X POST localhost:8000/refresh_token
Command line output
We test the return of the info interface with the username admin
and password admin
$ http -f GET localhost:8000/user/info "Authorization:Bearer xxxxxxxxx" "Content-Type: application/json"
or
$ curl -H 'Authorization:Bearer xxxxxx' -X POST localhost:8000/user/info
Command line output
We use an unauthorized token to test the return of the hello interface.
$ http -f GET localhost:8000/user/info "Authorization:Bearer xxxxxxxxx" "Content-Type: application/json"
or
curl -H 'Authorization:Bearer xxxxxx' -X POST localhost:8000/user/info
Command line output
Thanks again https://github.com/appleboy/gin-jwt