8000 GitHub - cherry-cup/jwt: A JWT plugin for gin, iris, go-frame, beego, go-zero, go-chassis, go-kit and other frameworks
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ jwt Public
forked from dobyte/jwt

A JWT plugin for gin, iris, go-frame, beego, go-zero, go-chassis, go-kit and other frameworks

License

Notifications You must be signed in to change notification settings

cherry-cup/jwt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JWT

A JWT plugin for gin, iris, go-frame, beego, go-zero, go-chassis, go-kit and other frameworks

Use

Download and install

go get github.com/dobyte/jwt

Demo

package main

import (
	"fmt"
	"log"
	"github.com/dobyte/jwt"
)

func main() {
	auth := jwt.NewJWT(
		jwt.WithIssuer("backend"),
		jwt.WithSignAlgorithm(jwt.HS256),
		jwt.WithSecretKey("secret"),
		jwt.WithValidDuration(3600),
		jwt.WithLookupLocations("header:Authorization"),
		jwt.WithIdentityKey("uid"),
	)

	token, err := auth.GenerateToken(jwt.Payload{
		"uid":     1,
		"account": "fuxiao",
	})
	if err != nil {
		log.Fatal("Generate token failed:" + err.Error())
	}

	fmt.Println(token)
}

Example

View demo example/server.go

API Demo

View demo example/jwt.postman.json

About

A JWT plugin for gin, iris, go-frame, beego, go-zero, go-chassis, go-kit and other frameworks

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%
0