kk_jwt

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: BSD-3-Clause Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateToken

func GenerateToken[T any](payload JwtPayload[T]) (tokenString string, err error)

GenerateToken 生成token eg 指定userId为int64类型,过期时间为9小时 tokenString := kk_jwt.GenerateToken[int64](userId, 9*time.Hour)

Types

type ConfigJWT

type ConfigJWT struct {
	Key        string
	ExpireTime int //minute
}

func (*ConfigJWT) Check

func (c *ConfigJWT) Check()

func (*ConfigJWT) Close

func (c *ConfigJWT) Close()

func (*ConfigJWT) Init

func (c *ConfigJWT) Init()

type JwtPayload

type JwtPayload[K any] struct {
	UserId   K
	Username string
	Platform int32
}

type MyClaims

type MyClaims[K any] struct {
	Payload JwtPayload[K]
	jwt.RegisteredClaims
}

func VerifyToken

func VerifyToken[T any](tokenString string) (myClaims *MyClaims[T], err error)

Jump to

Keyboard shortcuts

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