token

package
v0.0.0-...-d1aa883 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type Config

type Config struct {
	JWTSecret          string        `env:"JWT_SECRET"`
	JWTTokenExpiration time.Duration `env:"JWT_TOKEN_EXPIRATION" ,envDefault:"1h"`
}

type JWTMaker

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

func NewJWTMaker

func NewJWTMaker(secretKey string) *JWTMaker

func (*JWTMaker) CreateToken

func (maker *JWTMaker) CreateToken(userID uuid.UUID, duration time.Duration) (string, error)

func (*JWTMaker) ValidateToken

func (maker *JWTMaker) ValidateToken(token string) (*Payload, error)

type Payload

type Payload struct {
	ID       uuid.UUID `json:"id"`
	UserID   uuid.UUID `json:"userId"`
	Username string    `json:"username"`
}

Jump to

Keyboard shortcuts

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