jwt

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidToken = errors.New("invalid token")
	ExpiredToken = errors.New("expired token")
)
View Source
var ExpDelta int64 = 60 * 60 * 24

Functions

func GetToken

func GetToken(payload PayloadInterface, keys ...[]byte) (string, error)

多级签名 默认至少签名一次

func ParseToken

func ParseToken(token string, payload PayloadInterface, keys ...[]byte) (bool, error)

层级key校验 通过一次校验即可

Types

type Payload

type Payload struct {
	Iat int64 `json:"iat"` //token time
	Exp int64 `json:"exp"`
}

func (*Payload) GetExp

func (p *Payload) GetExp() int64

func (*Payload) GetIat

func (p *Payload) GetIat() int64

func (*Payload) IsExpired

func (p *Payload) IsExpired() bool

func (*Payload) SetExp

func (p *Payload) SetExp()

func (*Payload) SetIat

func (p *Payload) SetIat(t int64)

type PayloadInterface

type PayloadInterface interface {
	SetIat(int64)
	GetIat() int64
	SetExp()
	GetExp() int64
	IsExpired() bool
}

Jump to

Keyboard shortcuts

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