jwt

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: MIT Imports: 8 Imported by: 2

README

jwt

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expire1Hour added in v0.7.0

func Expire1Hour() string

func Expire1Month added in v0.7.0

func Expire1Month() string

func Expire1Week added in v0.7.0

func Expire1Week() string

func Expire1Year added in v0.7.0

func Expire1Year() string

func Expire2Hours added in v0.7.0

func Expire2Hours() string

func Expire3Days added in v0.7.0

func Expire3Days() string

func Expire5Minutes added in v0.7.0

func Expire5Minutes() string

func Expire72Hours added in v0.7.0

func Expire72Hours() string

func Expire100Years added in v0.7.0

func Expire100Years() string

func ExpiredAt added in v0.6.1

func ExpiredAt(tokens string) (*time.Time, error)

ExpiredAt 获取到期时间

func GenerateJwtKey added in v0.7.0

func GenerateJwtKey() string

GenerateJwtKey generate jwt key

func GenerateToken

func GenerateToken(content string) (string, error)

GenerateToken 生成token

func Init

func Init(config *Config)

Init 初始化

func InitClient added in v0.1.20210914101941

func InitClient(name string, config *Config)

InitClient init client

func InitClients added in v0.1.20210914101941

func InitClients(configs map[string]*Config)

InitClients init clients

func VerifyToken

func VerifyToken(tokens string) (string, error)

VerifyToken 格式化token

Types

type Config added in v0.1.20210914101941

type Config struct {
	Key    string `json:"key" yaml:"key"`       // 密钥
	Expire string `json:"expire" yaml:"expire"` // 超时时长,1s,10m
}

Config config struct

type JWT

type JWT struct {
	// contains filtered or unexported fields
}

JWT Struct Info

func GetClient added in v0.1.20210914101941

func GetClient(name string) *JWT

GetClient get client

func New added in v0.1.20210914101941

func New(config *Config) *JWT

New create instance

func (*JWT) ExpiredAt added in v0.6.0

func (receiver *JWT) ExpiredAt(tokenStr string) (*time.Time, error)

func (*JWT) GenerateToken

func (receiver *JWT) GenerateToken(content string) (token string, err error)

GenerateToken generate token

func (*JWT) VerifyToken

func (receiver *JWT) VerifyToken(tokenStr string) (string, error)

VerifyToken verify token

Jump to

Keyboard shortcuts

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