/gf-jwt

JWT plugin for GoFrame.

Primary LanguageGoMIT LicenseMIT

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