token

package
v0.0.0-...-e2fe045 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidToken     = errors.New("token is invalid")
	ErrExpiredToken     = errors.New("this token has expired")
	ErrInvalidKeyLength = errors.New("invalid key length")
)

Functions

func CreateSessionCookies

func CreateSessionCookies(paseto string, cfg *config.Config) (*http.Cookie, *http.Cookie)

func DestroySessionCookies

func DestroySessionCookies(cfg *config.Config) (*http.Cookie, *http.Cookie)

Types

type Maker

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

func NewMaker

func NewMaker(hexStr string) (*Maker, error)

func (Maker) CreateToken

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

func (Maker) VerifyToken

func (maker Maker) 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)

Jump to

Keyboard shortcuts

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