jwt

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2021 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, key []byte) (string, error)

func ParseToken

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

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