jwti

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Parser = jwt.NewParser()
)

Functions

func GenerateToken

func GenerateToken(claims jwt.Claims, secret interface{}) (string, error)

func NewStandardClaims

func NewStandardClaims(maxAge int64, sign string) *jwt.RegisteredClaims

func ParseToken

func ParseToken(claims jwt.Claims, token string, secret []byte) (*jwt.Token, error)

func ParseTokenWithKeyFunc

func ParseTokenWithKeyFunc(claims jwt.Claims, token string, f func(token *jwt.Token) (interface{}, error)) (*jwt.Token, error)

Types

type Claims

type Claims struct {
	UserId uint64 `json:"userId"`
	*jwt.RegisteredClaims
}

如果只存一个id,jwt的意义在哪呢,跟session_id有什么区别 jwt应该存放一些用户不能更改的信息,所以不能全存在jwt里 或者说用户每更改一次信息就刷新token(貌似可行) 有泛型这里多好写

type CustomClaims

type CustomClaims struct {
	CustomInfo interface{} `json:"customInfo"`
	*jwt.RegisteredClaims
}

Jump to

Keyboard shortcuts

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