jwt

package
v0.0.0-...-1f4ee57 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: MIT Imports: 4 Imported by: 0

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.StandardClaims

func ParseToken

func ParseToken(claims jwt.Claims, token, secret string) error

func ParseTokenWithKeyFunc

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

Types

type Claims

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

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

func (*Claims) Valid

func (claims *Claims) Valid(helper *jwt.ValidationHelper) error

type CustomClaims

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

func (*CustomClaims) Valid

func (claims *CustomClaims) Valid(helper *jwt.ValidationHelper) error

Jump to

Keyboard shortcuts

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