token

package
v0.0.0-...-2717cb5 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidToken = errors.New("token invalid")
	ErrExpiredToken = errors.New("token expired")
)

Functions

This section is empty.

Types

type Maker

type Maker interface {
	MakeToken(email string, duration time.Duration) (string, error)
	VerifyToken(token string) (*Payload, error)
}

func PasetoMaker

func PasetoMaker(symmeticKey string) (Maker, error)

type PasetoTokenMaker

type PasetoTokenMaker struct {
	// contains filtered or unexported fields
}

func NewPasetoTokenMaker

func NewPasetoTokenMaker() *PasetoTokenMaker

func (*PasetoTokenMaker) MakeToken

func (maker *PasetoTokenMaker) MakeToken(email string, duration time.Duration) (string, error)

func (*PasetoTokenMaker) VerifyToken

func (maker *PasetoTokenMaker) VerifyToken(token string) (*Payload, error)

type Payload

type Payload struct {
	ID        uuid.UUID `json:"id"`
	Email     string    `json:"email"`
	IssuedAt  time.Time `json:"issued_at"`
	ExpiredAt time.Time `json:"expired_at"`
}

func NewPayload

func NewPayload(email string, duration time.Duration) (*Payload, error)

func (*Payload) Valid

func (payload *Payload) Valid() error

Jump to

Keyboard shortcuts

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