jwti

package
v0.8.9 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: MIT, Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Parser          = jwt.NewParser()
	ErrInvalidToken = errors.New("invalid token")
)

Functions

func GenerateToken

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

func ParseToken

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

func ParseTokenWithKeyFunc

func ParseTokenWithKeyFunc(claims jwt.Claims, token string, f jwt.Keyfunc) (*jwt.Token, error)

func SetOptions added in v0.7.3

func SetOptions(options ...jwt.ParserOption)

Types

type Claims

type Claims[T any] struct {
	Data T `json:"data,omitempty"`
	*jwt.RegisteredClaims
}

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

func NewClaims added in v0.7.3

func NewClaims[T any](data T, maxAge int64, sign string) *Claims[T]

func (*Claims[T]) GenerateToken added in v0.7.3

func (c *Claims[T]) GenerateToken(secret interface{}) (string, error)

Jump to

Keyboard shortcuts

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