Skip to content

jinmao88/gf-jwt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gf-jwt

GF jwt plugin

This plugin is forked https://github.com/appleboy/gin-jwt plugin, modified to https://github.com/gogf/gf plugin.

英文 中文

Use

Download and install

$ go get github.com/jinmao88/gf-jwt

Import

import "github.com/jinmao88/gf-jwt"

Demo

Run example/main.go on the 8000 port.

$ go run example/main.go

api screenshot

Test the effect on the command line via httpie or curl.

Login interface:

$ 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

api screenshot

Refresh token interface:

$ 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

api screenshot

User info interface

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

api screenshot

User Authentication Interface

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

api screenshot

Thanks again https://github.com/appleboy/gin-jwt

About

GoFrame HTTP JWT middleware.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Go 100.0%