jwt

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Issuer                          = "Anonymous"
	SigningKey                      = []byte("Please replace the default signing key")
	SigningMethod jwt.SigningMethod = jwt.SigningMethodHS256

	ErrCustomClaimsInValid = errors.New("custom claims invalid")
)

Functions

func GenerateJWTToken

func GenerateJWTToken(customClaims *CustomClaims) (string, error)

func GetCustomData

func GetCustomData(tokenStr string, signingKey ...string) (string, error)

func SetIssuer

func SetIssuer(issuer string)

func SetSigningMethod

func SetSigningMethod(method jwt.SigningMethod)

func VerifyJWTToken

func VerifyJWTToken(tokenStr string, signingKey ...string) (bool, error)

Types

type CustomClaims

type CustomClaims struct {
	SigningKey []byte
	Data       string `json:"data"` // 任意字符串
	jwt.StandardClaims
}

func NewCustomClaims

func NewCustomClaims(data string, ttl time.Duration, signingKey ...string) *CustomClaims

NewCustomClaims 自定义请求权

type CustomData

type CustomData string

自定义携带数据结构

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL