Skip to content

joyoes/gf-jwt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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/gogf/gf-jwt

Import

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

Example

Check demo example/auth/auth.go and use ExtractClaims to customize user data.

Demo

Run example/server/server.go on the 8000 port.

$ go run example/server/server.go

api screenshot

Test the effect on the command line via httpie.

Login interface:

$ http -v --form POST localhost:8000/login username=admin password=admin

Command line output

api screenshot

Refresh token interface:

$ http -v -f GET localhost:8000/user/refresh_token "Authorization:Bearer xxxxxxxxx" "Content-Type: application/json"

Command line output

api screenshot

hello interface

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

api screenshot

User Authentication Interface

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

api screenshot

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

About

JWT plugin for GoFrame.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%