token

package
v0.0.0-...-2939996 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExpiredToken = errors.New("token as expired")
	ErrInvalidToken = errors.New("Invalid Token Error")
)

Functions

This section is empty.

Types

type JWTMarker

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

func (*JWTMarker) CreateToken

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

func (*JWTMarker) VerifyToken

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

type Maker

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

maker will be used to manage our tokens

func NewJWTMaker

func NewJWTMaker(secretKey string) (Maker, error)

func NewPasetoMarker

func NewPasetoMarker(symmetricKey string) (Maker, error)

type PasetoMarker

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

func (*PasetoMarker) CreateToken

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

func (*PasetoMarker) VerifyToken

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

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, 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