token

package
v0.0.0-...-ae18e74 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidToken = errors.New("Invalid token")
	ErrExpiredToken = errors.New("Expired token")
)

Different types of errors returned by the VerifyToken function

Functions

func CreateToken

func CreateToken(username string, duration time.Duration) (string, error)

Types

type Payload

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

func NewPayload

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

func VerifyToken

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

Jump to

Keyboard shortcuts

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